Class: Test::Unit::TestCase
- Inherits:
-
Object
- Object
- Test::Unit::TestCase
- Defined in:
- lib/contest.rb
Overview
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.
Class Method Summary collapse
- .context(*name, &block) ⇒ Object (also: describe)
- .setup(&block) ⇒ Object
- .teardown(&block) ⇒ Object
- .test(name, &block) ⇒ Object (also: should)
Class Method Details
.context(*name, &block) ⇒ Object Also known as: describe
33 34 35 36 37 38 |
# 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 |
.setup(&block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/contest.rb', line 19 def self.setup(&block) define_method :setup do super(&block) instance_eval(&block) end end |
.teardown(&block) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/contest.rb', line 26 def self.teardown(&block) define_method :teardown do instance_eval(&block) super(&block) end end |
.test(name, &block) ⇒ Object Also known as: should
40 41 42 |
# File 'lib/contest.rb', line 40 def self.test(name, &block) define_method(test_name(name), &block) end |