diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 6a6941c72a16ae9006ab945c774405045fa1e454..8c9ea2c0e8b0b1806933e8c109f4ea52dd5f451a 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -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 diff --git a/activesupport/test/test_case_test.rb b/activesupport/test/test_case_test.rb index d3d2ed8d7ae6cd409d0bbf756071e5f0059f40c5..dfbb8aa41d08f3fd0fc9913c178221ec22e3b0bf 100644 --- a/activesupport/test/test_case_test.rb +++ b/activesupport/test/test_case_test.rb @@ -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