diff options
Diffstat (limited to 'activesupport/lib/active_support/test_case.rb')
-rw-r--r-- | activesupport/lib/active_support/test_case.rb | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 197e73b3e8..f47329d026 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -1,24 +1,36 @@ -require 'test/unit/testcase' -require 'active_support/testing/default' -require 'active_support/testing/core_ext/test' - +require 'active_support/testing/setup_and_teardown' +require 'active_support/testing/assertions' +require 'active_support/testing/declarative' module ActiveSupport - class TestCase < Test::Unit::TestCase - # test "verify something" do - # ... - # end - def self.test(name, &block) - test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym - defined = instance_method(test_name) rescue false - raise "#{test_name} is already defined in #{self}" if defined - if block_given? - define_method(test_name, &block) - else - define_method(test_name) do - flunk "No implementation provided for #{name}" - end - end + # Prefer MiniTest with Test::Unit compatibility. + begin + require 'minitest/unit' + + # Hack around the test/unit autorun. + autorun_enabled = MiniTest::Unit.class_variable_get('@@installed_at_exit') + MiniTest::Unit.disable_autorun + require 'test/unit' + MiniTest::Unit.class_variable_set('@@installed_at_exit', autorun_enabled) + + class TestCase < ::Test::Unit::TestCase + Assertion = MiniTest::Assertion + end + + # Test::Unit compatibility. + rescue LoadError + require 'test/unit/testcase' + require 'active_support/testing/default' + + class TestCase < ::Test::Unit::TestCase + Assertion = Test::Unit::AssertionFailedError + include ActiveSupport::Testing::Default end end + + class TestCase + include ActiveSupport::Testing::SetupAndTeardown + include ActiveSupport::Testing::Assertions + extend ActiveSupport::Testing::Declarative + end end |