Permalink
Browse files

fix contest on 1.8

  • Loading branch information...
1 parent fd74972 commit 60f7b4735e4a8ab584a475483fc93c8491d8d513 @rkh rkh committed Jun 10, 2011
Showing with 14 additions and 6 deletions.
  1. +14 −6 test/contest.rb
View
@@ -35,20 +35,28 @@ def empty?
# block syntax. Adding setup or teardown instance methods defeats the purpose
# of this library.
class Test::Unit::TestCase
- def self.setup(&block)
- define_method :setup do
- super(&block)
+ def self.setup(&block) setup_blocks << block end
+ def self.teardown(&block) teardown_blocks << block end
+ def self.setup_blocks() @setup_blocks ||= [] end
+ def self.teardown_blocks() @teardown_blocks ||= [] end
+
+ def setup_blocks(base = self.class)
+ setup_blocks base.superclass if base.superclass.respond_to? :setup_blocks
+ base.setup_blocks.each do |block|
instance_eval(&block)
end
end
- def self.teardown(&block)
- define_method :teardown do
+ def teardown_blocks(base = self.class)
+ teardown_blocks base.superclass if base.superclass.respond_to? :teardown_blocks
+ base.teardown_blocks.each do |block|
instance_eval(&block)
- super(&block)
end
end
+ alias setup setup_blocks
+ alias teardown teardown_blocks
+
def self.context(*name, &block)
subclass = Class.new(self)
remove_tests(subclass)

0 comments on commit 60f7b47

Please sign in to comment.