Permalink
Browse files

rescue the assertion exception

  • Loading branch information...
1 parent f8964bd commit 0579f303ec0968e66a0e17bc494b06d0996aaffd @tenderlove tenderlove committed Jan 6, 2012
Showing with 8 additions and 13 deletions.
  1. +8 −13 activesupport/test/test_test.rb
@@ -61,24 +61,19 @@ def test_array_of_expressions
end
def test_array_of_expressions_identify_failure
- assert_difference ['@object.num', '1 + 1'] do
- @object.increment
+ assert_raises(MiniTest::Assertion) do
+ assert_difference ['@object.num', '1 + 1'] do
+ @object.increment
+ end
end
- fail 'should not get to here'
- rescue Exception => e
- assert_match(/didn't change by/, e.message)
- assert_match(/expected but was/, e.message)
end
def test_array_of_expressions_identify_failure_when_message_provided
- assert_difference ['@object.num', '1 + 1'], 1, 'something went wrong' do
- @object.increment
+ assert_raises(MiniTest::Assertion) do
+ assert_difference ['@object.num', '1 + 1'], 1, 'something went wrong' do
+ @object.increment
+ end
end
- fail 'should not get to here'
- rescue Exception => e
- assert_match(/something went wrong/, e.message)
- assert_match(/didn't change by/, e.message)
- assert_match(/expected but was/, e.message)
end
else
def default_test; end

0 comments on commit 0579f30

Please sign in to comment.