提交 eab8c3b9 编写于 作者: K Kasper Timm Hansen 提交者: GitHub

Merge pull request #26311 from y-yagi/use_inspect_for_show_value

use `inspect` for show `from` value
......@@ -147,7 +147,7 @@ def assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &b
retval = yield
unless from == UNTRACKED
error = "#{expression.inspect} isn't #{from}"
error = "#{expression.inspect} isn't #{from.inspect}"
error = "#{message}.\n#{error}" if message
assert from === before, error
end
......
......@@ -138,6 +138,15 @@ def test_assert_changes_with_from_option_with_wrong_value
end
end
def test_assert_changes_with_from_option_with_nil
error = assert_raises Minitest::Assertion do
assert_changes "@object.num", from: nil do
@object.increment
end
end
assert_equal "\"@object.num\" isn't nil", error.message
end
def test_assert_changes_with_to_option
assert_changes "@object.num", to: 1 do
@object.increment
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册