aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-13 02:34:42 -0800
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-11-13 02:34:42 -0800
commit0ed585adeb10d11badc892702d01e3c7addccbf4 (patch)
treed862bbf79ed1a16312763a4b3eb641c53e78b15b
parent3e53fe635c6e7b82609219422458574e2f74b551 (diff)
parent3791cac8747b5e36fe9619301a55d69f8feff982 (diff)
downloadrails-0ed585adeb10d11badc892702d01e3c7addccbf4.tar.gz
rails-0ed585adeb10d11badc892702d01e3c7addccbf4.tar.bz2
rails-0ed585adeb10d11badc892702d01e3c7addccbf4.zip
Merge pull request #8200 from freerange/3-2-stable-with-mocha-fixes
Fix 3-2-stable to work with Mocha v0.13.0
-rw-r--r--activesupport/lib/active_support/test_case.rb4
-rw-r--r--activesupport/lib/active_support/testing/mochaing.rb2
-rw-r--r--activesupport/lib/active_support/testing/setup_and_teardown.rb10
3 files changed, 11 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index 8d6c27e381..8f75cf98f4 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -9,7 +9,9 @@ require 'active_support/testing/mochaing'
require 'active_support/core_ext/kernel/reporting'
module ActiveSupport
- class TestCase < ::Test::Unit::TestCase
+ test_library = defined?(MiniTest) ? ::MiniTest : ::Test
+
+ class TestCase < test_library::Unit::TestCase
if defined? MiniTest
Assertion = MiniTest::Assertion
alias_method :method_name, :name if method_defined? :name
diff --git a/activesupport/lib/active_support/testing/mochaing.rb b/activesupport/lib/active_support/testing/mochaing.rb
index 4ad75a6681..0161476d79 100644
--- a/activesupport/lib/active_support/testing/mochaing.rb
+++ b/activesupport/lib/active_support/testing/mochaing.rb
@@ -1,5 +1,5 @@
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
diff --git a/activesupport/lib/active_support/testing/setup_and_teardown.rb b/activesupport/lib/active_support/testing/setup_and_teardown.rb
index f2268d1767..d21511d4db 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,14 +102,16 @@ 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