aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorlxxxvi <lxxxvi@users.noreply.github.com>2018-05-05 14:11:59 +0200
committerlxxxvi <lxxxvi@users.noreply.github.com>2018-05-05 14:11:59 +0200
commitf4f7659acf22f4f37938034bf78673c81c1511b6 (patch)
treee225d9d7501b0e1a57b57fd83800ba8174229bf4 /activesupport/lib
parent42b9e7e50c084e119a679cf155b70b5efc4d36ff (diff)
downloadrails-f4f7659acf22f4f37938034bf78673c81c1511b6.tar.gz
rails-f4f7659acf22f4f37938034bf78673c81c1511b6.tar.bz2
rails-f4f7659acf22f4f37938034bf78673c81c1511b6.zip
Clearer error message in assert_changes
When `to:` is passed to `assert_changes`, it now prints the well-known `"Expected: x\n Actual: y"` message. Before, the message only contained the actual value.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb4
1 files changed, 3 insertions, 1 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