use `inspect` for show `from` value

If `from` is nil, in order to avoid the blank is showed.
This commit is contained in:
yuuji.yaginuma 2016-08-29 09:05:32 +09:00
parent 9aa6a75eef
commit 6582c7c54a
2 changed files with 10 additions and 1 deletions

View File

@ -147,7 +147,7 @@ module ActiveSupport
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

View File

@ -138,6 +138,15 @@ class AssertDifferenceTest < ActiveSupport::TestCase
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