From a9aed2ac94d2e0d1a233a3c193985ae78d7e79e9 Mon Sep 17 00:00:00 2001 From: Michael Grosser Date: Fri, 16 Sep 2016 09:44:05 -0700 Subject: improve error message when include assertions fail assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong --- .../test/core_ext/array/conversions_test.rb | 46 +++++++++++----------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'activesupport/test/core_ext/array') diff --git a/activesupport/test/core_ext/array/conversions_test.rb b/activesupport/test/core_ext/array/conversions_test.rb index ccbdab19f0..469efcd934 100644 --- a/activesupport/test/core_ext/array/conversions_test.rb +++ b/activesupport/test/core_ext/array/conversions_test.rb @@ -97,28 +97,28 @@ class ToXmlTest < ActiveSupport::TestCase ].to_xml(skip_instruct: true, indent: 0) assert_equal '', xml.first(30) - assert xml.include?(%(26)), xml - assert xml.include?(%(820497600000)), xml - assert xml.include?(%(David)), xml - assert xml.include?(%(31)), xml - assert xml.include?(%(1.0)), xml - assert xml.include?(%(Jason)), xml + assert_includes xml, %(26), xml + assert_includes xml, %(820497600000), xml + assert_includes xml, %(David), xml + assert_includes xml, %(31), xml + assert_includes xml, %(1.0), xml + assert_includes xml, %(Jason), xml end def test_to_xml_with_non_hash_elements xml = %w[1 2 3].to_xml(skip_instruct: true, indent: 0) assert_equal '2)), xml + assert_includes xml, %(2), xml end def test_to_xml_with_non_hash_different_type_elements xml = [1, 2.0, "3"].to_xml(skip_instruct: true, indent: 0) assert_equal '1)), xml - assert xml.include?(%(2.0)), xml - assert xml.include?(%(object>3)), xml + assert_includes xml, %(1), xml + assert_includes xml, %(2.0), xml + assert_includes xml, %(object>3), xml end def test_to_xml_with_dedicated_name @@ -135,10 +135,10 @@ class ToXmlTest < ActiveSupport::TestCase ].to_xml(skip_instruct: true, skip_types: true, indent: 0) assert_equal "", xml.first(17) - assert xml.include?(%(Paulina)) - assert xml.include?(%(David)) - assert xml.include?(%(Evergreen)) - assert xml.include?(%(Jason)) + assert_includes xml, %(Paulina) + assert_includes xml, %(David) + assert_includes xml, %(Evergreen) + assert_includes xml, %(Jason) end def test_to_xml_with_indent_set @@ -147,10 +147,10 @@ class ToXmlTest < ActiveSupport::TestCase ].to_xml(skip_instruct: true, skip_types: true, indent: 4) assert_equal "\n ", xml.first(22) - assert xml.include?(%(\n Paulina)) - assert xml.include?(%(\n David)) - assert xml.include?(%(\n Evergreen)) - assert xml.include?(%(\n Jason)) + assert_includes xml, %(\n Paulina) + assert_includes xml, %(\n David) + assert_includes xml, %(\n Evergreen) + assert_includes xml, %(\n Jason) end def test_to_xml_with_dasherize_false @@ -159,8 +159,8 @@ class ToXmlTest < ActiveSupport::TestCase ].to_xml(skip_instruct: true, skip_types: true, indent: 0, dasherize: false) assert_equal "", xml.first(17) - assert xml.include?(%(Paulina)) - assert xml.include?(%(Evergreen)) + assert_includes xml, %(Paulina) + assert_includes xml, %(Evergreen) end def test_to_xml_with_dasherize_true @@ -169,8 +169,8 @@ class ToXmlTest < ActiveSupport::TestCase ].to_xml(skip_instruct: true, skip_types: true, indent: 0, dasherize: true) assert_equal "", xml.first(17) - assert xml.include?(%(Paulina)) - assert xml.include?(%(Evergreen)) + assert_includes xml, %(Paulina) + assert_includes xml, %(Evergreen) end def test_to_xml_with_instruct @@ -191,7 +191,7 @@ class ToXmlTest < ActiveSupport::TestCase builder.count 2 end - assert xml.include?(%(2)), xml + assert_includes xml, %(2), xml end def test_to_xml_with_empty -- cgit v1.2.3