Module: Nanotest::Contexts
Overview
“Simplicity means the achievement of maximum effect with minimum means.” –Koichi Kawana
Defined Under Namespace
Classes: Context
Instance Method Summary collapse
Instance Method Details
#context(&block) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/nanotest/contexts.rb', line 9 def context(&block) @_contexts ||= [] @_contexts << Context.new instance_eval(&block) @_contexts.pop end |
#setup(&block) ⇒ Object
16 17 18 |
# File 'lib/nanotest/contexts.rb', line 16 def setup(&block) @_contexts.last.setup = block end |
#teardown(&block) ⇒ Object
20 21 22 |
# File 'lib/nanotest/contexts.rb', line 20 def teardown(&block) @_contexts.last.teardown = block end |
#test(&block) ⇒ Object
24 25 26 27 28 |
# File 'lib/nanotest/contexts.rb', line 24 def test(&block) @_contexts.map {|c| c.setup }.compact.each {|s| s.call } block.call @_contexts.map {|c| c.teardown }.compact.each {|s| s.call } end |