Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #8872 from freerange/3-0-stable-with-mocha-fixes

Fix 3-0-stable to work with Mocha >= v0.13.0
  • Loading branch information...
commit d116e902c912322e1062183a507ca6b7917d80b3 2 parents 4c525b2 + bf91545
@rafaelfranca rafaelfranca authored
View
2  activesupport/lib/active_support/test_case.rb
@@ -8,7 +8,7 @@
require 'active_support/core_ext/kernel/reporting'
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
View
10 activesupport/lib/active_support/testing/setup_and_teardown.rb
@@ -56,7 +56,7 @@ module ForClassicTestUnit
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
@@ -78,6 +78,8 @@ def run(result)
begin
teardown
_run_teardown_callbacks
+ rescue Mocha::ExpectationError => e
+ add_failure(e.message, e.backtrace)
rescue Test::Unit::AssertionFailedError => e
add_failure(e.message, e.backtrace)
rescue Exception => e
@@ -95,12 +97,14 @@ def run(result)
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)
- else
+ elsif defined?(Mocha::Integration::TestUnit::AssertionCounter)
Mocha::Integration::TestUnit::AssertionCounter.new(result)
+ else
+ Mocha::Integration::AssertionCounter.new(test_case)
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.