Contest adds teardown
, test
and
context
as class methods, and the instance methods
setup
and teardown
now iterate on the
corresponding blocks. Note that all setup and teardown blocks must be
defined with the block syntax. Adding setup or teardown instance methods
defeats the purpose of this library.
# File lib/contest.rb, line 33 def self.context(*name, &block) subclass = Class.new(self) remove_tests(subclass) subclass.class_eval(&block) if block_given? const_set(context_name(name.join(" ")), subclass) end
# File lib/contest.rb, line 19 def self.setup(&block) define_method :setup do super(&block) instance_eval(&block) end end
# File lib/contest.rb, line 26 def self.teardown(&block) define_method :teardown do instance_eval(&block) super(&block) end end
# File lib/contest.rb, line 40 def self.test(name, &block) define_method(test_name(name), &block) end