aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-05-22 18:17:11 -0400
committerGitHub <noreply@github.com>2018-05-22 18:17:11 -0400
commitbe43b1f6de90a7035bf56caa60141675ecf9f088 (patch)
treeb0cbef1b6802663779d4541a3a218b8890cd7884 /activesupport
parent9480618f06ada9e06e8c95ca85d6242debad693a (diff)
parentf4f7659acf22f4f37938034bf78673c81c1511b6 (diff)
downloadrails-be43b1f6de90a7035bf56caa60141675ecf9f088.tar.gz
rails-be43b1f6de90a7035bf56caa60141675ecf9f088.tar.bz2
rails-be43b1f6de90a7035bf56caa60141675ecf9f088.zip
Merge pull request #32822 from lxxxvi/improved_error_message_in_assert_changes
Clearer error message in assert_changes
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb4
-rw-r--r--activesupport/test/test_case_test.rb2
2 files changed, 4 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index a891ff616d..6a56da384f 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -176,7 +176,9 @@ module ActiveSupport
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
diff --git a/activesupport/test/test_case_test.rb b/activesupport/test/test_case_test.rb
index 8a1ecb6b33..19901fad99 100644
--- a/activesupport/test/test_case_test.rb
+++ b/activesupport/test/test_case_test.rb
@@ -261,7 +261,7 @@ class AssertionsTest < ActiveSupport::TestCase
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