-
-
Save pietern/316742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# test/spec/mini 3 | |
# http://gist.github.com/25455 | |
# [email protected] | |
# 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) { super; instance_eval(&block) } end | |
def self.teardown(&block) define_method(:teardown) { super; instance_eval(&block) } end | |
end | |
(class << klass; self end).send(:define_method, :name) { name.gsub(/\W/,'_') } | |
klass.class_eval &block | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment