From f4f7659acf22f4f37938034bf78673c81c1511b6 Mon Sep 17 00:00:00 2001 From: lxxxvi Date: Sat, 5 May 2018 14:11:59 +0200 Subject: 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. --- activesupport/lib/active_support/testing/assertions.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport/lib') 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 -- cgit v1.2.3