diff options
Diffstat (limited to 'activesupport/lib/active_support/testing')
-rw-r--r-- | activesupport/lib/active_support/testing/mochaing.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/testing/setup_and_teardown.rb | 11 |
2 files changed, 9 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/testing/mochaing.rb b/activesupport/lib/active_support/testing/mochaing.rb index 4ad75a6681..ae4e7e9a1f 100644 --- a/activesupport/lib/active_support/testing/mochaing.rb +++ b/activesupport/lib/active_support/testing/mochaing.rb @@ -1,7 +1,7 @@ begin - silence_warnings { require 'mocha' } + silence_warnings { require 'mocha/setup' } rescue LoadError # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh. Object.const_set :Mocha, Module.new Mocha.const_set :ExpectationError, Class.new(StandardError) -end
\ No newline at end of file +end diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb index f2268d1767..e5353f65cf 100644 --- a/activesupport/lib/active_support/testing/setup_and_teardown.rb +++ b/activesupport/lib/active_support/testing/setup_and_teardown.rb @@ -61,7 +61,7 @@ module ActiveSupport def run(result) return if @method_name.to_s == "default_test" - mocha_counter = retrieve_mocha_counter(result) + mocha_counter = retrieve_mocha_counter(self, result) yield(Test::Unit::TestCase::STARTED, name) @_result = result @@ -83,6 +83,8 @@ module ActiveSupport begin teardown run_callbacks :teardown + rescue Mocha::ExpectationError => e + add_failure(e.message, e.backtrace) rescue Test::Unit::AssertionFailedError => e add_failure(e.message, e.backtrace) rescue Exception => e @@ -100,19 +102,20 @@ module ActiveSupport protected - def retrieve_mocha_counter(result) #:nodoc: + def retrieve_mocha_counter(test_case, result) #:nodoc: if respond_to?(:mocha_verify) # using mocha if defined?(Mocha::TestCaseAdapter::AssertionCounter) Mocha::TestCaseAdapter::AssertionCounter.new(result) elsif defined?(Mocha::Integration::TestUnit::AssertionCounter) Mocha::Integration::TestUnit::AssertionCounter.new(result) - else + elsif defined?(Mocha::MonkeyPatching::TestUnit::AssertionCounter) Mocha::MonkeyPatching::TestUnit::AssertionCounter.new(result) + else + Mocha::Integration::AssertionCounter.new(test_case) end end end end - end end end |