module Assert::Context::SetupDSL
Public Instance Methods
around(&block)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 19 def around(&block) arounds << block end
arounds()
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 33 def arounds @arounds ||= [] end
run_arounds(scope, &run_block)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 45 def run_arounds(scope, &run_block) context_block = arounds.compact.reverse.reduce(run_block) do |run_b, around_b| Proc.new{ scope.instance_exec(run_b, &around_b) } end if superclass.respond_to?(:run_arounds) superclass.run_arounds(scope, &context_block) else context_block.call end end
run_setups(scope)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 58 def run_setups(scope) # setup the parent... superclass.run_setups(scope) if superclass.respond_to?(:run_setups) # ... before you setup the child setups.compact.each do |setup| setup.is_a?(::Proc) ? scope.instance_eval(&setup) : scope.send(setup) end end
run_teardowns(scope)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 67 def run_teardowns(scope) # teardown the child... teardowns.compact.each do |teardown| if teardown.is_a?(::Proc) scope.instance_eval(&teardown) else scope.send(teardown) end end # ... before the parent superclass.run_teardowns(scope) if superclass.respond_to?(:run_teardowns) end
setup(method_name = nil, &block)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 23 def setup(method_name = nil, &block) setups << (block || method_name) end
Also aliased as: before
setup_once(&block)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 7 def setup_once(&block) suite.setup(&block) end
Also aliased as: before_once, startup
setups()
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 37 def setups @setups ||= [] end
teardown(method_name = nil, &block)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 28 def teardown(method_name = nil, &block) teardowns << (block || method_name) end
Also aliased as: after
teardown_once(&block)
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 13 def teardown_once(&block) suite.teardown(&block) end
Also aliased as: after_once, shutdown
teardowns()
click to toggle source
# File lib/assert/context/setup_dsl.rb, line 41 def teardowns @teardowns ||= [] end