rtomayko (owner)

Fork Of

gist: 25455 by defunkt test/spec/mini 2

Revisions

gist: 201298 Download_button fork
public
Public Clone URL: git://gist.github.com/201298.git
Embed All Files: show embed
test-spec-mini.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
##
# test/spec/mini 2
# http://gist.github.com/25455
# chris@ozmm.org
# file:lib/test/spec/mini.rb
#
def context(*args, &block)
  return super unless (name = args.first) && block
  require 'test/unit'
  klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
    def self.test(name, &block)
      define_method("test_#{name.gsub(/\W/,'_')}", &block) if block
    end
    def self.xtest(*args) end
    def self.setup(&block) define_method(:setup, &block) end
    def self.teardown(&block) define_method(:teardown, &block) end
  end
  klass.class_eval &block
end