diff options
Diffstat (limited to 'activesupport/test/test_test.rb')
-rw-r--r-- | activesupport/test/test_test.rb | 60 |
1 files changed, 39 insertions, 21 deletions
diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb index 9516556844..3e6ac811a4 100644 --- a/activesupport/test/test_test.rb +++ b/activesupport/test/test_test.rb @@ -15,6 +15,17 @@ class AssertDifferenceTest < ActiveSupport::TestCase @object.num = 0 end + def test_assert_not + assert_equal true, assert_not(nil) + assert_equal true, assert_not(false) + + e = assert_raises(MiniTest::Assertion) { assert_not true } + assert_equal 'Expected true to be nil or false', e.message + + e = assert_raises(MiniTest::Assertion) { assert_not true, 'custom' } + assert_equal 'custom', e.message + end + def test_assert_no_difference assert_no_difference '@object.num' do # ... @@ -81,17 +92,21 @@ class AssertBlankTest < ActiveSupport::TestCase NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ] def test_assert_blank_true - BLANK.each { |v| assert_blank v } + BLANK.each { |value| + assert_deprecated { assert_blank value } + } end def test_assert_blank_false NOT_BLANK.each { |v| - begin - assert_blank v - fail 'should not get to here' - rescue Exception => e - assert_match(/is not blank/, e.message) - end + assert_deprecated { + begin + assert_blank v + fail 'should not get to here' + rescue Exception => e + assert_match(/is not blank/, e.message) + end + } } end end @@ -101,17 +116,21 @@ class AssertPresentTest < ActiveSupport::TestCase NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ] def test_assert_present_true - NOT_BLANK.each { |v| assert_present v } + NOT_BLANK.each { |v| + assert_deprecated { assert_present v } + } end def test_assert_present_false BLANK.each { |v| - begin - assert_present v - fail 'should not get to here' - rescue Exception => e - assert_match(/is blank/, e.message) - end + assert_deprecated { + begin + assert_present v + fail 'should not get to here' + rescue Exception => e + assert_match(/is blank/, e.message) + end + } } end end @@ -122,12 +141,12 @@ end # Setup and teardown callbacks. class SetupAndTeardownTest < ActiveSupport::TestCase setup :reset_callback_record, :foo - teardown :foo, :sentinel, :foo + teardown :foo, :sentinel def test_inherited_setup_callbacks assert_equal [:reset_callback_record, :foo], self.class._setup_callbacks.map(&:raw_filter) assert_equal [:foo], @called_back - assert_equal [:foo, :sentinel, :foo], self.class._teardown_callbacks.map(&:raw_filter) + assert_equal [:foo, :sentinel], self.class._teardown_callbacks.map(&:raw_filter) end def setup @@ -147,7 +166,7 @@ class SetupAndTeardownTest < ActiveSupport::TestCase end def sentinel - assert_equal [:foo, :foo], @called_back + assert_equal [:foo], @called_back end end @@ -159,7 +178,7 @@ class SubclassSetupAndTeardownTest < SetupAndTeardownTest def test_inherited_setup_callbacks assert_equal [:reset_callback_record, :foo, :bar], self.class._setup_callbacks.map(&:raw_filter) assert_equal [:foo, :bar], @called_back - assert_equal [:foo, :sentinel, :foo, :bar], self.class._teardown_callbacks.map(&:raw_filter) + assert_equal [:foo, :sentinel, :bar], self.class._teardown_callbacks.map(&:raw_filter) end protected @@ -168,7 +187,7 @@ class SubclassSetupAndTeardownTest < SetupAndTeardownTest end def sentinel - assert_equal [:foo, :bar, :bar, :foo], @called_back + assert_equal [:foo, :bar, :bar], @called_back end end @@ -182,7 +201,6 @@ class TestCaseTaggedLoggingTest < ActiveSupport::TestCase end def test_logs_tagged_with_current_test_case - tagged_logger.info 'test' - assert_equal "[#{self.class.name}] [#{__name__}] test\n", @out.string + assert_match "#{self.class}: #{__name__}\n", @out.string end end |