mirror of https://github.com/rails/rails
Merge pull request #44811 from pjambet/pj/improve-assert-changes-error-message
Improve default message for assert_changes
This commit is contained in:
commit
b97c308f91
|
@ -179,7 +179,7 @@ module ActiveSupport
|
|||
retval = _assert_nothing_raised_or_warn("assert_changes", &block)
|
||||
|
||||
unless from == UNTRACKED
|
||||
error = "Expected change from #{from.inspect}"
|
||||
error = "Expected change from #{from.inspect}, got #{before}"
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert from === before, error
|
||||
end
|
||||
|
@ -192,7 +192,7 @@ module ActiveSupport
|
|||
refute_equal before, after, error
|
||||
|
||||
unless to == UNTRACKED
|
||||
error = "Expected change to #{to}\n"
|
||||
error = "Expected change to #{to}, got #{after}\n"
|
||||
error = "#{message}.\n#{error}" if message
|
||||
assert to === after, error
|
||||
end
|
||||
|
|
|
@ -192,7 +192,8 @@ class AssertionsTest < ActiveSupport::TestCase
|
|||
@object.increment
|
||||
end
|
||||
end
|
||||
assert_equal "Expected change from nil", error.message
|
||||
|
||||
assert_equal "Expected change from nil, got 0", error.message
|
||||
end
|
||||
|
||||
def test_assert_changes_with_to_option
|
||||
|
@ -277,7 +278,7 @@ class AssertionsTest < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
assert_equal "@object.num should be 1.\nExpected change to 1\n", error.message
|
||||
assert_equal "@object.num should be 1.\nExpected change to 1, got -1\n", error.message
|
||||
end
|
||||
|
||||
def test_assert_no_changes_pass
|
||||
|
|
Loading…
Reference in New Issue