1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Add missing test cases for #assert_no_difference

This commit is contained in:
Akshay Vishnoi 2014-06-13 06:52:58 +05:30
parent caf1bfccc6
commit bb5c1321d6

View file

@ -28,12 +28,30 @@ class AssertDifferenceTest < ActiveSupport::TestCase
assert_equal 'custom', e.message assert_equal 'custom', e.message
end end
def test_assert_no_difference def test_assert_no_difference_pass
assert_no_difference '@object.num' do assert_no_difference '@object.num' do
# ... # ...
end end
end end
def test_assert_no_difference_fail
error = assert_raises(Minitest::Assertion) do
assert_no_difference '@object.num' do
@object.increment
end
end
assert_equal "\"@object.num\" didn't change by 0.\nExpected: 0\n Actual: 1", error.message
end
def test_assert_no_difference_with_message_fail
error = assert_raises(Minitest::Assertion) do
assert_no_difference '@object.num', 'Object Changed' do
@object.increment
end
end
assert_equal "Object Changed.\n\"@object.num\" didn't change by 0.\nExpected: 0\n Actual: 1", error.message
end
def test_assert_difference def test_assert_difference
assert_difference '@object.num', +1 do assert_difference '@object.num', +1 do
@object.increment @object.increment