Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test that assert_not returns true. Use assert_raises instead of doing…

… begin/rescue/else.
  • Loading branch information...
commit 8a130ece7e265f1e94abef8d64d5c6880797e831 1 parent 54a6518
@jeremy jeremy authored
Showing with 7 additions and 17 deletions.
  1. +7 −17 activesupport/test/test_test.rb
View
24 activesupport/test/test_test.rb
@@ -16,24 +16,14 @@ def decrement
end
def test_assert_not
- assert_not nil
- 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
+ assert_equal true, assert_not(nil)
+ assert_equal true, assert_not(false)
- 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 }
+ 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
Please sign in to comment.
Something went wrong with that request. Please try again.