Permalink
Browse files

fix Module.test

  • Loading branch information...
1 parent 4529256 commit acf2b8bfc05c2507b7fd0a296e6db98b210c0907 Sven Fuchs committed Jul 21, 2010
Showing with 16 additions and 20 deletions.
  1. +16 −20 lib/test_declarative.rb
View
@@ -1,24 +1,20 @@
-module TestDeclarative
- def self.included(base)
- base.class_eval do
- def self.test(name, &block)
- test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
- defined = instance_method(test_name) rescue false
- raise "#{test_name} is already defined in #{self}" if defined
- if block_given?
- define_method(test_name, &block)
- else
- define_method(test_name) do
- flunk "No implementation provided for #{name}"
- end
+targets = [Module]
+targets << Test::Unit::TestCase if defined?(Test::Unit::TestCase)
+targets << MiniTest::Unit::TestCase if defined?(MiniTest::Unit::TestCase)
+
+targets.each do |target|
+ target.class_eval do
+ def test(name, &block)
+ test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
+ defined = instance_method(test_name) rescue false
+ raise "#{test_name} is already defined in #{self}" if defined
+ if block_given?
+ define_method(test_name, &block)
+ else
+ define_method(test_name) do
+ flunk "No implementation provided for #{name}"
end
end
end
end
-end
-
-classes = [Module]
-classes << Test::Unit::TestCase if defined?(Test::Unit::TestCase)
-classes << MiniTest::Unit::TestCase if defined?(MiniTest::Unit::TestCase)
-
-classes.each { |c| c.send(:include, TestDeclarative) }
+end

0 comments on commit acf2b8b

Please sign in to comment.