未验证 提交 be43b1f6 编写于 作者: R Rafael França 提交者: GitHub

Merge pull request #32822 from lxxxvi/improved_error_message_in_assert_changes

Clearer error message in assert_changes
......@@ -176,7 +176,9 @@ def assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &b
assert before != after, error
unless to == UNTRACKED
error = "#{expression.inspect} didn't change to #{to}"
error = "#{expression.inspect} didn't change to as expected\n"
error = "#{error}Expected: #{to.inspect}\n"
error = "#{error} Actual: #{after.inspect}"
error = "#{message}.\n#{error}" if message
assert to === after, error
end
......
......@@ -261,7 +261,7 @@ def test_assert_changes_with_message
end
end
assert_equal "@object.num should 1.\n\"@object.num\" didn't change to 1", error.message
assert_equal "@object.num should 1.\n\"@object.num\" didn't change to as expected\nExpected: 1\n Actual: -1", error.message
end
def test_assert_no_changes_pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册