aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorJames Mead <james@floehopper.org>2012-08-26 17:45:26 +0100
committerJames Mead <james@floehopper.org>2012-11-13 08:25:14 +0000
commitc3e186ec8dcb2ec26d5d56f3e89123b1350c4a6f (patch)
treeba6aead7d3c3e05002e3b69823fb6d4567b56f76 /activesupport
parent716bdfc01d45a61d211dbd766f494cb984fc9f9c (diff)
downloadrails-c3e186ec8dcb2ec26d5d56f3e89123b1350c4a6f.tar.gz
rails-c3e186ec8dcb2ec26d5d56f3e89123b1350c4a6f.tar.bz2
rails-c3e186ec8dcb2ec26d5d56f3e89123b1350c4a6f.zip
Use MiniTest in Ruby 1.8 if it is available.
ActiveSupport::TestCase was always inheriting from Test::Unit::TestCase. This works fine in Ruby 1.9 where Test::Unit::TestCase is a thin wrapper around MiniTest::Unit::TestCase, but does not work in Ruby 1.8 if the MiniTest gem is used. What happens is that ActiveSupport inherits from the Test::Unit::TestCase provided by the standard library, but then since Minitest is defined, it then seems to proceed on the assumption that ActiveSupport::TestCase has MiniTest::Unit::TestCase in its ancestor chain. However, in this case it does not. The fix is simply to choose which test library TestCase to inherit from using the same logic used elsewhere to detect MiniTest. I noticed this bug causing issues when using MiniTest and Mocha in Ruby 1.8, but there may well be other issues.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/test_case.rb4
1 files changed, 3 insertions, 1 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