diff options
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r-- | activesupport/test/core_ext/array/conversions_test.rb | 46 | ||||
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 68 | ||||
-rw-r--r-- | activesupport/test/core_ext/module/concerning_test.rb | 6 | ||||
-rw-r--r-- | activesupport/test/core_ext/range_ext_test.rb | 6 |
4 files changed, 63 insertions, 63 deletions
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 '<objects type="array"><object>', xml.first(30) - assert xml.include?(%(<age type="integer">26</age>)), xml - assert xml.include?(%(<age-in-millis type="integer">820497600000</age-in-millis>)), xml - assert xml.include?(%(<name>David</name>)), xml - assert xml.include?(%(<age type="integer">31</age>)), xml - assert xml.include?(%(<age-in-millis type="decimal">1.0</age-in-millis>)), xml - assert xml.include?(%(<name>Jason</name>)), xml + assert_includes xml, %(<age type="integer">26</age>), xml + assert_includes xml, %(<age-in-millis type="integer">820497600000</age-in-millis>), xml + assert_includes xml, %(<name>David</name>), xml + assert_includes xml, %(<age type="integer">31</age>), xml + assert_includes xml, %(<age-in-millis type="decimal">1.0</age-in-millis>), xml + assert_includes xml, %(<name>Jason</name>), xml end def test_to_xml_with_non_hash_elements xml = %w[1 2 3].to_xml(skip_instruct: true, indent: 0) assert_equal '<strings type="array"><string', xml.first(29) - assert xml.include?(%(<string>2</string>)), xml + assert_includes xml, %(<string>2</string>), 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 '<objects type="array"><object', xml.first(29) - assert xml.include?(%(<object type="integer">1</object>)), xml - assert xml.include?(%(<object type="float">2.0</object>)), xml - assert xml.include?(%(object>3</object>)), xml + assert_includes xml, %(<object type="integer">1</object>), xml + assert_includes xml, %(<object type="float">2.0</object>), xml + assert_includes xml, %(object>3</object>), 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 "<objects><object>", xml.first(17) - assert xml.include?(%(<street-address>Paulina</street-address>)) - assert xml.include?(%(<name>David</name>)) - assert xml.include?(%(<street-address>Evergreen</street-address>)) - assert xml.include?(%(<name>Jason</name>)) + assert_includes xml, %(<street-address>Paulina</street-address>) + assert_includes xml, %(<name>David</name>) + assert_includes xml, %(<street-address>Evergreen</street-address>) + assert_includes xml, %(<name>Jason</name>) 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 "<objects>\n <object>", xml.first(22) - assert xml.include?(%(\n <street-address>Paulina</street-address>)) - assert xml.include?(%(\n <name>David</name>)) - assert xml.include?(%(\n <street-address>Evergreen</street-address>)) - assert xml.include?(%(\n <name>Jason</name>)) + assert_includes xml, %(\n <street-address>Paulina</street-address>) + assert_includes xml, %(\n <name>David</name>) + assert_includes xml, %(\n <street-address>Evergreen</street-address>) + assert_includes xml, %(\n <name>Jason</name>) 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 "<objects><object>", xml.first(17) - assert xml.include?(%(<street_address>Paulina</street_address>)) - assert xml.include?(%(<street_address>Evergreen</street_address>)) + assert_includes xml, %(<street_address>Paulina</street_address>) + assert_includes xml, %(<street_address>Evergreen</street_address>) 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 "<objects><object>", xml.first(17) - assert xml.include?(%(<street-address>Paulina</street-address>)) - assert xml.include?(%(<street-address>Evergreen</street-address>)) + assert_includes xml, %(<street-address>Paulina</street-address>) + assert_includes xml, %(<street-address>Evergreen</street-address>) end def test_to_xml_with_instruct @@ -191,7 +191,7 @@ class ToXmlTest < ActiveSupport::TestCase builder.count 2 end - assert xml.include?(%(<count>2</count>)), xml + assert_includes xml, %(<count>2</count>), xml end def test_to_xml_with_empty diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index e457cb866d..ae35adb19b 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -1127,63 +1127,63 @@ class HashToXmlTest < ActiveSupport::TestCase def test_one_level xml = { name: "David", street: "Paulina" }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street>Paulina</street>)) - assert xml.include?(%(<name>David</name>)) + assert_includes xml, %(<street>Paulina</street>) + assert_includes xml, %(<name>David</name>) end def test_one_level_dasherize_false xml = { name: "David", street_name: "Paulina" }.to_xml(@xml_options.merge(dasherize: false)) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street_name>Paulina</street_name>)) - assert xml.include?(%(<name>David</name>)) + assert_includes xml, %(<street_name>Paulina</street_name>) + assert_includes xml, %(<name>David</name>) end def test_one_level_dasherize_true xml = { name: "David", street_name: "Paulina" }.to_xml(@xml_options.merge(dasherize: true)) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street-name>Paulina</street-name>)) - assert xml.include?(%(<name>David</name>)) + assert_includes xml, %(<street-name>Paulina</street-name>) + assert_includes xml, %(<name>David</name>) end def test_one_level_camelize_true xml = { name: "David", street_name: "Paulina" }.to_xml(@xml_options.merge(camelize: true)) assert_equal "<Person>", xml.first(8) - assert xml.include?(%(<StreetName>Paulina</StreetName>)) - assert xml.include?(%(<Name>David</Name>)) + assert_includes xml, %(<StreetName>Paulina</StreetName>) + assert_includes xml, %(<Name>David</Name>) end def test_one_level_camelize_lower xml = { name: "David", street_name: "Paulina" }.to_xml(@xml_options.merge(camelize: :lower)) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<streetName>Paulina</streetName>)) - assert xml.include?(%(<name>David</name>)) + assert_includes xml, %(<streetName>Paulina</streetName>) + assert_includes xml, %(<name>David</name>) end def test_one_level_with_types xml = { name: "David", street: "Paulina", age: 26, age_in_millis: 820497600000, moved_on: Date.new(2005, 11, 15), resident: :yes }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street>Paulina</street>)) - assert xml.include?(%(<name>David</name>)) - assert xml.include?(%(<age type="integer">26</age>)) - assert xml.include?(%(<age-in-millis type="integer">820497600000</age-in-millis>)) - assert xml.include?(%(<moved-on type="date">2005-11-15</moved-on>)) - assert xml.include?(%(<resident type="symbol">yes</resident>)) + assert_includes xml, %(<street>Paulina</street>) + assert_includes xml, %(<name>David</name>) + assert_includes xml, %(<age type="integer">26</age>) + assert_includes xml, %(<age-in-millis type="integer">820497600000</age-in-millis>) + assert_includes xml, %(<moved-on type="date">2005-11-15</moved-on>) + assert_includes xml, %(<resident type="symbol">yes</resident>) end def test_one_level_with_nils xml = { name: "David", street: "Paulina", age: nil }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street>Paulina</street>)) - assert xml.include?(%(<name>David</name>)) - assert xml.include?(%(<age nil="true"/>)) + assert_includes xml, %(<street>Paulina</street>) + assert_includes xml, %(<name>David</name>) + assert_includes xml, %(<age nil="true"/>) end def test_one_level_with_skipping_types xml = { name: "David", street: "Paulina", age: nil }.to_xml(@xml_options.merge(skip_types: true)) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street>Paulina</street>)) - assert xml.include?(%(<name>David</name>)) - assert xml.include?(%(<age nil="true"/>)) + assert_includes xml, %(<street>Paulina</street>) + assert_includes xml, %(<name>David</name>) + assert_includes xml, %(<age nil="true"/>) end def test_one_level_with_yielding @@ -1192,37 +1192,37 @@ class HashToXmlTest < ActiveSupport::TestCase end assert_equal "<person>", xml.first(8) - assert xml.include?(%(<street>Paulina</street>)) - assert xml.include?(%(<name>David</name>)) - assert xml.include?(%(<creator>Rails</creator>)) + assert_includes xml, %(<street>Paulina</street>) + assert_includes xml, %(<name>David</name>) + assert_includes xml, %(<creator>Rails</creator>) end def test_two_levels xml = { name: "David", address: { street: "Paulina" } }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<address><street>Paulina</street></address>)) - assert xml.include?(%(<name>David</name>)) + assert_includes xml, %(<address><street>Paulina</street></address>) + assert_includes xml, %(<name>David</name>) end def test_two_levels_with_second_level_overriding_to_xml xml = { name: "David", address: { street: "Paulina" }, child: IWriteMyOwnXML.new }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<address><street>Paulina</street></address>)) - assert xml.include?(%(<level_one><second_level>content</second_level></level_one>)) + assert_includes xml, %(<address><street>Paulina</street></address>) + assert_includes xml, %(<level_one><second_level>content</second_level></level_one>) end def test_two_levels_with_array xml = { name: "David", addresses: [{ street: "Paulina" }, { street: "Evergreen" }] }.to_xml(@xml_options) assert_equal "<person>", xml.first(8) - assert xml.include?(%(<addresses type="array"><address>)) - assert xml.include?(%(<address><street>Paulina</street></address>)) - assert xml.include?(%(<address><street>Evergreen</street></address>)) - assert xml.include?(%(<name>David</name>)) + assert_includes xml, %(<addresses type="array"><address>) + assert_includes xml, %(<address><street>Paulina</street></address>) + assert_includes xml, %(<address><street>Evergreen</street></address>) + assert_includes xml, %(<name>David</name>) end def test_three_levels_with_array xml = { name: "David", addresses: [{ streets: [ { name: "Paulina" }, { name: "Paulina" } ] } ] }.to_xml(@xml_options) - assert xml.include?(%(<addresses type="array"><address><streets type="array"><street><name>)) + assert_includes xml, %(<addresses type="array"><address><streets type="array"><street><name>) end def test_timezoned_attributes diff --git a/activesupport/test/core_ext/module/concerning_test.rb b/activesupport/test/core_ext/module/concerning_test.rb index 038cbf1f2f..098036828a 100644 --- a/activesupport/test/core_ext/module/concerning_test.rb +++ b/activesupport/test/core_ext/module/concerning_test.rb @@ -4,7 +4,7 @@ require "active_support/core_ext/module/concerning" class ModuleConcerningTest < ActiveSupport::TestCase def test_concerning_declares_a_concern_and_includes_it_immediately klass = Class.new { concerning(:Foo) {} } - assert klass.ancestors.include?(klass::Foo), klass.ancestors.inspect + assert_includes klass.ancestors, klass::Foo, klass.ancestors.inspect end end @@ -21,10 +21,10 @@ class ModuleConcernTest < ActiveSupport::TestCase assert klass.const_defined?(:Baz, false) assert !ModuleConcernTest.const_defined?(:Baz) assert_kind_of ActiveSupport::Concern, klass::Baz - assert !klass.ancestors.include?(klass::Baz), klass.ancestors.inspect + assert_not_includes klass.ancestors, klass::Baz, klass.ancestors.inspect # Public method visibility by default - assert klass::Baz.public_instance_methods.map(&:to_s).include?("should_be_public") + assert_includes klass::Baz.public_instance_methods.map(&:to_s), "should_be_public" # Calls included hook assert_equal 1, Class.new { include klass::Baz }.instance_variable_get("@foo") diff --git a/activesupport/test/core_ext/range_ext_test.rb b/activesupport/test/core_ext/range_ext_test.rb index 25e6693e4d..fc0e72e09a 100644 --- a/activesupport/test/core_ext/range_ext_test.rb +++ b/activesupport/test/core_ext/range_ext_test.rb @@ -66,15 +66,15 @@ class RangeTest < ActiveSupport::TestCase end def test_exclusive_end_should_not_include_identical_with_inclusive_end - assert !(1...10).include?(1..10) + assert_not_includes (1...10), 1..10 end def test_should_not_include_overlapping_first - assert !(2..8).include?(1..3) + assert_not_includes (2..8), 1..3 end def test_should_not_include_overlapping_last - assert !(2..8).include?(5..9) + assert_not_includes (2..8), 5..9 end def test_should_include_identical_exclusive_with_floats |