aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/test_case.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-11-07 12:45:48 -0500
committerJeremy Kemper <jeremy@bitsweat.net>2008-11-07 12:45:48 -0500
commit18099b0fd53b8f9ba88ef46bdd910347f03c72c5 (patch)
tree763fef4bb4966040d2b80c19301bf9572feb02db /activesupport/lib/active_support/test_case.rb
parent7b28a55a2bc9bedd5a8c8dec0a8a02166927ef16 (diff)
downloadrails-18099b0fd53b8f9ba88ef46bdd910347f03c72c5.tar.gz
rails-18099b0fd53b8f9ba88ef46bdd910347f03c72c5.tar.bz2
rails-18099b0fd53b8f9ba88ef46bdd910347f03c72c5.zip
Rework testing extensions to reflect the recent miniunit upheaval
Diffstat (limited to 'activesupport/lib/active_support/test_case.rb')
-rw-r--r--activesupport/lib/active_support/test_case.rb44
1 files changed, 24 insertions, 20 deletions
diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb
index cdd884f918..be38eb64a1 100644
--- a/activesupport/lib/active_support/test_case.rb
+++ b/activesupport/lib/active_support/test_case.rb
@@ -1,28 +1,32 @@
-require 'test/unit/testcase'
require 'active_support/testing/setup_and_teardown'
require 'active_support/testing/assertions'
-require 'active_support/testing/default'
+require 'active_support/testing/declarative'
module ActiveSupport
- class TestCase < ::Test::Unit::TestCase
- include ActiveSupport::Testing::SetupAndTeardown
- include ActiveSupport::Testing::Assertions
- include ActiveSupport::Testing::Default
+ # Prefer MiniTest with Test::Unit compatibility.
+ # Hacks around the test/unit autorun.
+ begin
+ require 'minitest/unit'
+ MiniTest::Unit.disable_autorun
+ require 'test/unit'
+
+ class TestCase < ::Test::Unit::TestCase
+ @@installed_at_exit = false
+ end
+
+ # Test::Unit compatibility.
+ rescue LoadError
+ require 'test/unit/testcase'
+ require 'active_support/testing/default'
- # 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
+ class TestCase < ::Test::Unit::TestCase
+ include ActiveSupport::Testing::Default
end
end
+
+ class TestCase
+ include ActiveSupport::Testing::SetupAndTeardown
+ include ActiveSupport::Testing::Assertions
+ extend ActiveSupport::Testing::Declarative
+ end
end