From 392d03a2920707dd44f9dfb5d6d0348ee701579e Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Wed, 31 Aug 2016 08:47:48 +0900 Subject: [PATCH] use `message` that specified in argument to error message --- activesupport/lib/active_support/testing/assertions.rb | 2 +- activesupport/test/test_case_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 8c9ea2c0e8..28cf2953bf 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -159,7 +159,7 @@ module ActiveSupport error = "#{message}.\n#{error}" if message assert_not_equal before, after, error else - message = "#{expression.inspect} didn't change to #{to}" + error = "#{expression.inspect} didn't change to #{to}" 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 dfbb8aa41d..d769a8c145 100644 --- a/activesupport/test/test_case_test.rb +++ b/activesupport/test/test_case_test.rb @@ -211,6 +211,15 @@ class AssertDifferenceTest < ActiveSupport::TestCase end end + def test_assert_changes_with_message + error = assert_raises Minitest::Assertion do + assert_changes "@object.num", "@object.num should 1", to: 1 do + end + end + + assert_equal "@object.num should 1.\n\"@object.num\" didn't change to 1", error.message + end + def test_assert_no_changes_pass assert_no_changes "@object.num" do # ...