diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/abstract_unit.rb | 1 | ||||
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/core_ext/module/model_naming_test.rb | 8 | ||||
-rw-r--r-- | activesupport/test/deprecation_test.rb | 26 | ||||
-rw-r--r-- | activesupport/test/test_test.rb | 19 |
5 files changed, 30 insertions, 26 deletions
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb index 9d8c252f86..a11ff25e41 100644 --- a/activesupport/test/abstract_unit.rb +++ b/activesupport/test/abstract_unit.rb @@ -5,6 +5,7 @@ require 'test/unit' $:.unshift "#{File.dirname(__FILE__)}/../lib" $:.unshift File.dirname(__FILE__) require 'active_support' +require 'active_support/test_case' if RUBY_VERSION < '1.9' $KCODE = 'UTF8' diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 5cd52d8d79..6fe0a98d39 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -1,6 +1,6 @@ require 'abstract_unit' -class DurationTest < Test::Unit::TestCase +class DurationTest < ActiveSupport::TestCase def test_inspect assert_equal '1 month', 1.month.inspect assert_equal '1 month and 1 day', (1.month + 1.day).inspect diff --git a/activesupport/test/core_ext/module/model_naming_test.rb b/activesupport/test/core_ext/module/model_naming_test.rb index fc73fa5c36..d08349dd97 100644 --- a/activesupport/test/core_ext/module/model_naming_test.rb +++ b/activesupport/test/core_ext/module/model_naming_test.rb @@ -2,18 +2,18 @@ require 'abstract_unit' class ModelNamingTest < Test::Unit::TestCase def setup - @name = ActiveSupport::ModelName.new('Post::TrackBack') + @model_name = ActiveSupport::ModelName.new('Post::TrackBack') end def test_singular - assert_equal 'post_track_back', @name.singular + assert_equal 'post_track_back', @model_name.singular end def test_plural - assert_equal 'post_track_backs', @name.plural + assert_equal 'post_track_backs', @model_name.plural end def test_partial_path - assert_equal 'post/track_backs/track_back', @name.partial_path + assert_equal 'post/track_backs/track_back', @model_name.partial_path end end diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index 27e9573ce2..73a1f9959c 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -32,7 +32,7 @@ class Deprecatee end -class DeprecationTest < Test::Unit::TestCase +class DeprecationTest < ActiveSupport::TestCase def setup # Track the last warning. @old_behavior = ActiveSupport::Deprecation.behavior @@ -143,19 +143,21 @@ class DeprecationTest < Test::Unit::TestCase assert_deprecated(/you now need to do something extra for this one/) { @dtc.d } end - def test_assertion_failed_error_doesnt_spout_deprecation_warnings - error_class = Class.new(StandardError) do - def message - ActiveSupport::Deprecation.warn 'warning in error message' - super + unless defined?(::MiniTest) + def test_assertion_failed_error_doesnt_spout_deprecation_warnings + error_class = Class.new(StandardError) do + def message + ActiveSupport::Deprecation.warn 'warning in error message' + super + end end - end - raise error_class.new('hmm') + raise error_class.new('hmm') - rescue => e - error = Test::Unit::Error.new('testing ur doodz', e) - assert_not_deprecated { error.message } - assert_nil @last_message + rescue => e + error = Test::Unit::Error.new('testing ur doodz', e) + assert_not_deprecated { error.message } + assert_nil @last_message + end end end diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb index 4e253848f6..89fae1a9e4 100644 --- a/activesupport/test/test_test.rb +++ b/activesupport/test/test_test.rb @@ -1,7 +1,6 @@ require 'abstract_unit' -require 'active_support/test_case' -class AssertDifferenceTest < Test::Unit::TestCase +class AssertDifferenceTest < ActiveSupport::TestCase def setup @object = Class.new do attr_accessor :num @@ -66,8 +65,8 @@ class AssertDifferenceTest < Test::Unit::TestCase @object.increment end fail 'should not get to here' - rescue Test::Unit::AssertionFailedError => e - assert_equal "<1 + 1> was the expression that failed.\n<3> expected but was\n<2>.", e.message + rescue Exception => e + assert_equal "<3> expected but was\n<2>.", e.message end def test_array_of_expressions_identify_failure_when_message_provided @@ -75,8 +74,8 @@ class AssertDifferenceTest < Test::Unit::TestCase @object.increment end fail 'should not get to here' - rescue Test::Unit::AssertionFailedError => e - assert_equal "something went wrong.\n<1 + 1> was the expression that failed.\n<3> expected but was\n<2>.", e.message + rescue Exception => e + assert_equal "something went wrong.\n<3> expected but was\n<2>.", e.message end else def default_test; end @@ -84,15 +83,17 @@ class AssertDifferenceTest < Test::Unit::TestCase end # These should always pass -class NotTestingThingsTest < Test::Unit::TestCase - include ActiveSupport::Testing::Default +if defined? ActiveSupport::Testing::Default + class NotTestingThingsTest < Test::Unit::TestCase + include ActiveSupport::Testing::Default + end end class AlsoDoingNothingTest < ActiveSupport::TestCase end # Setup and teardown callbacks. -class SetupAndTeardownTest < Test::Unit::TestCase +class SetupAndTeardownTest < ActiveSupport::TestCase setup :reset_callback_record, :foo teardown :foo, :sentinel, :foo |