Permalink
Browse files

Mocha 0.9.0 compatibility for test setup/teardown callbacks

  • Loading branch information...
1 parent a5156d9 commit d8a555e1376ed509c9f81c42229c5e923153eeb3 @jeremy jeremy committed Nov 20, 2008
Showing with 6 additions and 4 deletions.
  1. +6 −4 activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -86,28 +86,30 @@ def run_with_callbacks_and_testunit(result) #:nodoc:
def run_with_callbacks_and_mocha(result)
return if @method_name.to_s == "default_test"
+ assertion_counter = Mocha::TestCaseAdapter::AssertionCounter.new(result)
yield(Test::Unit::TestCase::STARTED, name)
@_result = result
begin
- mocha_setup
begin
run_callbacks :setup
setup
__send__(@method_name)
- mocha_verify { add_assertion }
+ mocha_verify(assertion_counter)
rescue Mocha::ExpectationError => e
add_failure(e.message, e.backtrace)
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
- rescue StandardError, ScriptError
+ rescue Exception
+ raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
add_error($!)
ensure
begin
teardown
run_callbacks :teardown, :enumerator => :reverse_each
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
- rescue StandardError, ScriptError
+ rescue Exception
+ raise if Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS.include? $!.class
add_error($!)
end
end

0 comments on commit d8a555e

Please sign in to comment.