Test that assert_not returns true. Use assert_raises instead of doing begin/rescue/else.

This commit is contained in:
Jeremy Kemper 2012-12-28 21:47:42 -07:00
parent 54a65183e7
commit 8a130ece7e
1 changed files with 6 additions and 16 deletions

View File

@ -16,24 +16,14 @@ class AssertDifferenceTest < ActiveSupport::TestCase
end
def test_assert_not
assert_not nil
assert_not false
assert_equal true, assert_not(nil)
assert_equal true, assert_not(false)
begin
assert_not true
rescue Exception => e
assert_equal 'Expected true to be nil or false', e.message
else
fail 'assert_not true should fail'
end
e = assert_raises(MiniTest::Assertion) { assert_not true }
assert_equal 'Expected true to be nil or false', e.message
begin
assert_not true, 'custom'
rescue Exception => e
assert_equal 'custom', e.message
else
fail 'assert_not true should fail'
end
e = assert_raises(MiniTest::Assertion) { assert_not true, 'custom' }
assert_equal 'custom', e.message
end
def test_assert_no_difference