lib/assert/test.rb in assert-0.5.0 vs lib/assert/test.rb in assert-0.6.0
- old
+ new
@@ -28,11 +28,18 @@
def run(view=nil)
@results.view = view
run_scope = @context_class.new(self)
capture_output(StringIO.new(@output, "w+")) do
begin
+ # run any assert style 'setup do' setups
@context_class.setup(run_scope)
+ # run any classic test/unit style 'def setup' setups
+ if run_scope.respond_to?(:setup)
+ run_scope.setup
+ end
+
+ # run the actual test code
if @code.kind_of?(::Proc)
run_scope.instance_eval(&@code)
elsif run_scope.respond_to?(@code.to_s)
run_scope.send(@code.to_s)
end
@@ -40,9 +47,14 @@
@results << Result::Skip.new(self.name, err)
rescue Exception => err
@results << Result::Error.new(self.name, err)
ensure
begin
+ # run any classic test/unit style 'def teardown' teardowns
+ if run_scope.respond_to?(:teardown)
+ run_scope.teardown
+ end
+ # run any assert style 'teardown do' teardowns
@context_class.teardown(run_scope)
rescue Exception => teardown_err
@results << Result::Error.new(self.name, teardown_err)
end
end