Skip to content

Commit 0579f30

Browse files
committed
rescue the assertion exception
1 parent f8964bd commit 0579f30

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

activesupport/test/test_test.rb

+8-13
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,19 @@ def test_array_of_expressions
6161
end
6262

6363
def test_array_of_expressions_identify_failure
64-
assert_difference ['@object.num', '1 + 1'] do
65-
@object.increment
64+
assert_raises(MiniTest::Assertion) do
65+
assert_difference ['@object.num', '1 + 1'] do
66+
@object.increment
67+
end
6668
end
67-
fail 'should not get to here'
68-
rescue Exception => e
69-
assert_match(/didn't change by/, e.message)
70-
assert_match(/expected but was/, e.message)
7169
end
7270

7371
def test_array_of_expressions_identify_failure_when_message_provided
74-
assert_difference ['@object.num', '1 + 1'], 1, 'something went wrong' do
75-
@object.increment
72+
assert_raises(MiniTest::Assertion) do
73+
assert_difference ['@object.num', '1 + 1'], 1, 'something went wrong' do
74+
@object.increment
75+
end
7676
end
77-
fail 'should not get to here'
78-
rescue Exception => e
79-
assert_match(/something went wrong/, e.message)
80-
assert_match(/didn't change by/, e.message)
81-
assert_match(/expected but was/, e.message)
8277
end
8378
else
8479
def default_test; end

0 commit comments

Comments
 (0)