From 0d50cae996c51630361e8514e1f168b0c48957e1 Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Wed, 24 Jan 2018 21:14:10 -0500 Subject: Use respond_to test helpers --- .../module/attribute_accessor_per_thread_test.rb | 8 ++++---- .../test/core_ext/module/attribute_accessor_test.rb | 8 ++++---- activesupport/test/core_ext/module/concerning_test.rb | 8 ++++---- .../test/core_ext/module/remove_method_test.rb | 4 ++-- activesupport/test/core_ext/module_test.rb | 18 +++++++++--------- activesupport/test/core_ext/object/try_test.rb | 8 ++++---- activesupport/test/core_ext/time_with_zone_test.rb | 12 ++++++------ 7 files changed, 33 insertions(+), 33 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb b/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb index e0fbd1002c..e0e331fc91 100644 --- a/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb +++ b/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb @@ -43,22 +43,22 @@ class ModuleAttributeAccessorPerThreadTest < ActiveSupport::TestCase assert_respond_to @class, :foo assert_respond_to @class, :foo= assert_respond_to @object, :bar - assert !@object.respond_to?(:bar=) + assert_not_respond_to @object, :bar= end.join end def test_should_not_create_instance_reader Thread.new do assert_respond_to @class, :shaq - assert !@object.respond_to?(:shaq) + assert_not_respond_to @object, :shaq end.join end def test_should_not_create_instance_accessors Thread.new do assert_respond_to @class, :camp - assert !@object.respond_to?(:camp) - assert !@object.respond_to?(:camp=) + assert_not_respond_to @object, :camp + assert_not_respond_to @object, :camp= end.join end diff --git a/activesupport/test/core_ext/module/attribute_accessor_test.rb b/activesupport/test/core_ext/module/attribute_accessor_test.rb index f1d6859a88..33c583947a 100644 --- a/activesupport/test/core_ext/module/attribute_accessor_test.rb +++ b/activesupport/test/core_ext/module/attribute_accessor_test.rb @@ -65,18 +65,18 @@ class ModuleAttributeAccessorTest < ActiveSupport::TestCase assert_respond_to @module, :foo assert_respond_to @module, :foo= assert_respond_to @object, :bar - assert !@object.respond_to?(:bar=) + assert_not_respond_to @object, :bar= end def test_should_not_create_instance_reader assert_respond_to @module, :shaq - assert !@object.respond_to?(:shaq) + assert_not_respond_to @object, :shaq end def test_should_not_create_instance_accessors assert_respond_to @module, :camp - assert !@object.respond_to?(:camp) - assert !@object.respond_to?(:camp=) + assert_not_respond_to @object, :camp + assert_not_respond_to @object, :camp= end def test_should_raise_name_error_if_attribute_name_is_invalid diff --git a/activesupport/test/core_ext/module/concerning_test.rb b/activesupport/test/core_ext/module/concerning_test.rb index 192c3d5a9c..969434766f 100644 --- a/activesupport/test/core_ext/module/concerning_test.rb +++ b/activesupport/test/core_ext/module/concerning_test.rb @@ -55,10 +55,10 @@ class ModuleConcernTest < ActiveSupport::TestCase end def test_using_class_methods_blocks_instead_of_ClassMethods_module - assert !Foo.respond_to?(:will_be_orphaned) - assert Foo.respond_to?(:hacked_on) - assert Foo.respond_to?(:nicer_dsl) - assert Foo.respond_to?(:doesnt_clobber) + assert_not_respond_to Foo, :will_be_orphaned + assert_respond_to Foo, :hacked_on + assert_respond_to Foo, :nicer_dsl + assert_respond_to Foo, :doesnt_clobber # Orphan in Foo::ClassMethods, not Bar::ClassMethods. assert Foo.const_defined?(:ClassMethods) diff --git a/activesupport/test/core_ext/module/remove_method_test.rb b/activesupport/test/core_ext/module/remove_method_test.rb index 8493be8d08..a18fc0a5e4 100644 --- a/activesupport/test/core_ext/module/remove_method_test.rb +++ b/activesupport/test/core_ext/module/remove_method_test.rb @@ -32,14 +32,14 @@ class RemoveMethodTest < ActiveSupport::TestCase RemoveMethodTests::A.class_eval { remove_possible_method(:do_something) } - assert !RemoveMethodTests::A.new.respond_to?(:do_something) + assert_not_respond_to RemoveMethodTests::A.new, :do_something end def test_remove_singleton_method_from_an_object RemoveMethodTests::A.class_eval { remove_possible_singleton_method(:do_something_else) } - assert !RemoveMethodTests::A.respond_to?(:do_something_else) + assert_not_respond_to RemoveMethodTests::A, :do_something_else end def test_redefine_method_in_an_object diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index e918823074..4ed8ffc933 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -383,9 +383,9 @@ class ModuleTest < ActiveSupport::TestCase end def test_delegate_missing_to_affects_respond_to - assert DecoratedTester.new(@david).respond_to?(:name) - assert_not DecoratedTester.new(@david).respond_to?(:private_name) - assert_not DecoratedTester.new(@david).respond_to?(:my_fake_method) + assert_respond_to DecoratedTester.new(@david), :name + assert_not_respond_to DecoratedTester.new(@david), :private_name + assert_not_respond_to DecoratedTester.new(@david), :my_fake_method assert DecoratedTester.new(@david).respond_to?(:name, true) assert_not DecoratedTester.new(@david).respond_to?(:private_name, true) @@ -414,8 +414,8 @@ class ModuleTest < ActiveSupport::TestCase place = location.new(Somewhere.new("Such street", "Sad city")) - assert_not place.respond_to?(:street) - assert_not place.respond_to?(:city) + assert_not_respond_to place, :street + assert_not_respond_to place, :city assert place.respond_to?(:street, true) # Asking for private method assert place.respond_to?(:city, true) @@ -432,12 +432,12 @@ class ModuleTest < ActiveSupport::TestCase place = location.new(Somewhere.new("Such street", "Sad city")) - assert_not place.respond_to?(:street) - assert_not place.respond_to?(:city) + assert_not_respond_to place, :street + assert_not_respond_to place, :city - assert_not place.respond_to?(:the_street) + assert_not_respond_to place, :the_street assert place.respond_to?(:the_street, true) - assert_not place.respond_to?(:the_city) + assert_not_respond_to place, :the_city assert place.respond_to?(:the_city, true) end end diff --git a/activesupport/test/core_ext/object/try_test.rb b/activesupport/test/core_ext/object/try_test.rb index fe68b24bf5..40d6cdd28e 100644 --- a/activesupport/test/core_ext/object/try_test.rb +++ b/activesupport/test/core_ext/object/try_test.rb @@ -10,25 +10,25 @@ class ObjectTryTest < ActiveSupport::TestCase def test_nonexisting_method method = :undefined_method - assert !@string.respond_to?(method) + assert_not_respond_to @string, method assert_nil @string.try(method) end def test_nonexisting_method_with_arguments method = :undefined_method - assert !@string.respond_to?(method) + assert_not_respond_to @string, method assert_nil @string.try(method, "llo", "y") end def test_nonexisting_method_bang method = :undefined_method - assert !@string.respond_to?(method) + assert_not_respond_to @string, method assert_raise(NoMethodError) { @string.try!(method) } end def test_nonexisting_method_with_arguments_bang method = :undefined_method - assert !@string.respond_to?(method) + assert_not_respond_to @string, method assert_raise(NoMethodError) { @string.try!(method, "llo", "y") } end diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index b25747eadb..521b87878a 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -1035,8 +1035,8 @@ class TimeWithZoneMethodsForTimeAndDateTimeTest < ActiveSupport::TestCase def test_nil_time_zone Time.use_zone nil do - assert !@t.in_time_zone.respond_to?(:period), "no period method" - assert !@dt.in_time_zone.respond_to?(:period), "no period method" + assert_not_respond_to @t.in_time_zone, :period, "no period method" + assert_not_respond_to @dt.in_time_zone, :period, "no period method" end end @@ -1224,7 +1224,7 @@ class TimeWithZoneMethodsForDate < ActiveSupport::TestCase def test_nil_time_zone with_tz_default nil do - assert !@d.in_time_zone.respond_to?(:period), "no period method" + assert_not_respond_to @d.in_time_zone, :period, "no period method" end end @@ -1273,9 +1273,9 @@ class TimeWithZoneMethodsForString < ActiveSupport::TestCase def test_nil_time_zone with_tz_default nil do - assert !@s.in_time_zone.respond_to?(:period), "no period method" - assert !@u.in_time_zone.respond_to?(:period), "no period method" - assert !@z.in_time_zone.respond_to?(:period), "no period method" + assert_not_respond_to @s.in_time_zone, :period, "no period method" + assert_not_respond_to @u.in_time_zone, :period, "no period method" + assert_not_respond_to @z.in_time_zone, :period, "no period method" end end -- cgit v1.2.3 From 211adb47e76b358ea15a3f756431c042ab231c23 Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Wed, 24 Jan 2018 22:04:11 -0500 Subject: Change refute to assert_not --- activesupport/test/core_ext/class_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/class_test.rb b/activesupport/test/core_ext/class_test.rb index 9cc006fc63..5ea288738e 100644 --- a/activesupport/test/core_ext/class_test.rb +++ b/activesupport/test/core_ext/class_test.rb @@ -30,11 +30,11 @@ class ClassTest < ActiveSupport::TestCase def test_descendants_excludes_singleton_classes klass = Parent.new.singleton_class - refute Parent.descendants.include?(klass), "descendants should not include singleton classes" + assert_not Parent.descendants.include?(klass), "descendants should not include singleton classes" end def test_subclasses_excludes_singleton_classes klass = Parent.new.singleton_class - refute Parent.subclasses.include?(klass), "subclasses should not include singleton classes" + assert_not Parent.subclasses.include?(klass), "subclasses should not include singleton classes" end end -- cgit v1.2.3 From 94333a4c31bd10c1f358c538a167e6a4589bae2d Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Thu, 25 Jan 2018 18:14:09 -0500 Subject: Use assert_predicate and assert_not_predicate --- .../test/core_ext/date_and_time_behavior.rb | 20 +++---- activesupport/test/core_ext/date_ext_test.rb | 4 +- activesupport/test/core_ext/date_time_ext_test.rb | 6 +-- activesupport/test/core_ext/hash_ext_test.rb | 6 +-- .../test/core_ext/module/anonymous_test.rb | 8 +-- .../core_ext/module/attribute_aliasing_test.rb | 14 ++--- .../test/core_ext/module/reachable_test.rb | 20 +++---- activesupport/test/core_ext/module_test.rb | 2 +- activesupport/test/core_ext/string_ext_test.rb | 62 +++++++++++----------- activesupport/test/core_ext/time_ext_test.rb | 4 +- activesupport/test/core_ext/time_with_zone_test.rb | 14 ++--- 11 files changed, 80 insertions(+), 80 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/date_and_time_behavior.rb b/activesupport/test/core_ext/date_and_time_behavior.rb index 1176ed647a..1422f135a8 100644 --- a/activesupport/test/core_ext/date_and_time_behavior.rb +++ b/activesupport/test/core_ext/date_and_time_behavior.rb @@ -361,28 +361,28 @@ module DateAndTimeBehavior end def test_on_weekend_on_saturday - assert date_time_init(2015, 1, 3, 0, 0, 0).on_weekend? - assert date_time_init(2015, 1, 3, 15, 15, 10).on_weekend? + assert_predicate date_time_init(2015, 1, 3, 0, 0, 0), :on_weekend? + assert_predicate date_time_init(2015, 1, 3, 15, 15, 10), :on_weekend? end def test_on_weekend_on_sunday - assert date_time_init(2015, 1, 4, 0, 0, 0).on_weekend? - assert date_time_init(2015, 1, 4, 15, 15, 10).on_weekend? + assert_predicate date_time_init(2015, 1, 4, 0, 0, 0), :on_weekend? + assert_predicate date_time_init(2015, 1, 4, 15, 15, 10), :on_weekend? end def test_on_weekend_on_monday - assert_not date_time_init(2015, 1, 5, 0, 0, 0).on_weekend? - assert_not date_time_init(2015, 1, 5, 15, 15, 10).on_weekend? + assert_not_predicate date_time_init(2015, 1, 5, 0, 0, 0), :on_weekend? + assert_not_predicate date_time_init(2015, 1, 5, 15, 15, 10), :on_weekend? end def test_on_weekday_on_sunday - assert_not date_time_init(2015, 1, 4, 0, 0, 0).on_weekday? - assert_not date_time_init(2015, 1, 4, 15, 15, 10).on_weekday? + assert_not_predicate date_time_init(2015, 1, 4, 0, 0, 0), :on_weekday? + assert_not_predicate date_time_init(2015, 1, 4, 15, 15, 10), :on_weekday? end def test_on_weekday_on_monday - assert date_time_init(2015, 1, 5, 0, 0, 0).on_weekday? - assert date_time_init(2015, 1, 5, 15, 15, 10).on_weekday? + assert_predicate date_time_init(2015, 1, 5, 0, 0, 0), :on_weekday? + assert_predicate date_time_init(2015, 1, 5, 15, 15, 10), :on_weekday? end def with_bw_default(bw = :monday) diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb index 23d17956df..b8652884ce 100644 --- a/activesupport/test/core_ext/date_ext_test.rb +++ b/activesupport/test/core_ext/date_ext_test.rb @@ -386,11 +386,11 @@ end class DateExtBehaviorTest < ActiveSupport::TestCase def test_date_acts_like_date - assert Date.new.acts_like_date? + assert_predicate Date.new, :acts_like_date? end def test_blank? - assert_not Date.new.blank? + assert_not_predicate Date.new, :blank? end def test_freeze_doesnt_clobber_memoized_instance_methods diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index f4c9dfcb25..9bd87b3c5e 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -315,15 +315,15 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase end def test_acts_like_date - assert DateTime.new.acts_like_date? + assert_predicate DateTime.new, :acts_like_date? end def test_acts_like_time - assert DateTime.new.acts_like_time? + assert_predicate DateTime.new, :acts_like_time? end def test_blank? - assert_not DateTime.new.blank? + assert_not_predicate DateTime.new, :blank? end def test_utc? diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index 17952e9fc7..50b811e79f 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -1061,7 +1061,7 @@ class HashToXmlTest < ActiveSupport::TestCase XML alert_at = Hash.from_xml(alert_xml)["alert"]["alert_at"] - assert alert_at.utc? + assert_predicate alert_at, :utc? assert_equal Time.utc(2008, 2, 10, 15, 30, 45), alert_at end @@ -1072,7 +1072,7 @@ class HashToXmlTest < ActiveSupport::TestCase XML alert_at = Hash.from_xml(alert_xml)["alert"]["alert_at"] - assert alert_at.utc? + assert_predicate alert_at, :utc? assert_equal Time.utc(2008, 2, 10, 15, 30, 45), alert_at end @@ -1083,7 +1083,7 @@ class HashToXmlTest < ActiveSupport::TestCase XML alert_at = Hash.from_xml(alert_xml)["alert"]["alert_at"] - assert alert_at.utc? + assert_predicate alert_at, :utc? assert_equal 2050, alert_at.year assert_equal 2, alert_at.month assert_equal 10, alert_at.day diff --git a/activesupport/test/core_ext/module/anonymous_test.rb b/activesupport/test/core_ext/module/anonymous_test.rb index 606f22c9b5..e03c217015 100644 --- a/activesupport/test/core_ext/module/anonymous_test.rb +++ b/activesupport/test/core_ext/module/anonymous_test.rb @@ -5,12 +5,12 @@ require "active_support/core_ext/module/anonymous" class AnonymousTest < ActiveSupport::TestCase test "an anonymous class or module are anonymous" do - assert Module.new.anonymous? - assert Class.new.anonymous? + assert_predicate Module.new, :anonymous? + assert_predicate Class.new, :anonymous? end test "a named class or module are not anonymous" do - assert !Kernel.anonymous? - assert !Object.anonymous? + assert_not_predicate Kernel, :anonymous? + assert_not_predicate Object, :anonymous? end end diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb index 187a0f4da2..81aac224f9 100644 --- a/activesupport/test/core_ext/module/attribute_aliasing_test.rb +++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb @@ -30,15 +30,15 @@ class AttributeAliasingTest < ActiveSupport::TestCase def test_attribute_alias e = AttributeAliasing::Email.new - assert !e.subject? + assert_not_predicate e, :subject? e.title = "Upgrade computer" assert_equal "Upgrade computer", e.subject - assert e.subject? + assert_predicate e, :subject? e.subject = "We got a long way to go" assert_equal "We got a long way to go", e.title - assert e.title? + assert_predicate e, :title? end def test_aliasing_to_uppercase_attributes @@ -47,15 +47,15 @@ class AttributeAliasingTest < ActiveSupport::TestCase # to more sensible ones, everything goes *foof*. e = AttributeAliasing::Email.new - assert !e.body? - assert !e.Data? + assert_not_predicate e, :body? + assert_not_predicate e, :Data? e.body = "No, really, this is not a joke." assert_equal "No, really, this is not a joke.", e.Data - assert e.Data? + assert_predicate e, :Data? e.Data = "Uppercased methods are the suck" assert_equal "Uppercased methods are the suck", e.body - assert e.body? + assert_predicate e, :body? end end diff --git a/activesupport/test/core_ext/module/reachable_test.rb b/activesupport/test/core_ext/module/reachable_test.rb index 097a72fa5b..f356d46957 100644 --- a/activesupport/test/core_ext/module/reachable_test.rb +++ b/activesupport/test/core_ext/module/reachable_test.rb @@ -6,15 +6,15 @@ require "active_support/core_ext/module/reachable" class AnonymousTest < ActiveSupport::TestCase test "an anonymous class or module is not reachable" do assert_deprecated do - assert !Module.new.reachable? - assert !Class.new.reachable? + assert_not_predicate Module.new, :reachable? + assert_not_predicate Class.new, :reachable? end end test "ordinary named classes or modules are reachable" do assert_deprecated do - assert Kernel.reachable? - assert Object.reachable? + assert_predicate Kernel, :reachable? + assert_predicate Object, :reachable? end end @@ -26,8 +26,8 @@ class AnonymousTest < ActiveSupport::TestCase self.class.send(:remove_const, :M) assert_deprecated do - assert !c.reachable? - assert !m.reachable? + assert_not_predicate c, :reachable? + assert_not_predicate m, :reachable? end end @@ -42,10 +42,10 @@ class AnonymousTest < ActiveSupport::TestCase eval "module M; end" assert_deprecated do - assert C.reachable? - assert M.reachable? - assert !c.reachable? - assert !m.reachable? + assert_predicate C, :reachable? + assert_predicate M, :reachable? + assert_not_predicate c, :reachable? + assert_not_predicate m, :reachable? end end end diff --git a/activesupport/test/core_ext/module_test.rb b/activesupport/test/core_ext/module_test.rb index 4ed8ffc933..ebbe9c304c 100644 --- a/activesupport/test/core_ext/module_test.rb +++ b/activesupport/test/core_ext/module_test.rb @@ -347,7 +347,7 @@ class ModuleTest < ActiveSupport::TestCase def test_delegation_with_method_arguments has_block = HasBlock.new(Block.new) - assert has_block.hello? + assert_predicate has_block, :hello? end def test_delegate_missing_to_with_method diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 5c5abe9fd1..472190277e 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -259,8 +259,8 @@ class StringInflectionsTest < ActiveSupport::TestCase end def test_string_inquiry - assert "production".inquiry.production? - assert !"production".inquiry.development? + assert_predicate "production".inquiry, :production? + assert_not_predicate "production".inquiry, :development? end def test_truncate @@ -317,7 +317,7 @@ class StringInflectionsTest < ActiveSupport::TestCase end def test_truncate_should_not_be_html_safe - assert !"Hello World!".truncate(12).html_safe? + assert_not_predicate "Hello World!".truncate(12), :html_safe? end def test_remove @@ -639,7 +639,7 @@ end class StringBehaviourTest < ActiveSupport::TestCase def test_acts_like_string - assert "Bambi".acts_like_string? + assert_predicate "Bambi", :acts_like_string? end end @@ -654,10 +654,10 @@ class CoreExtStringMultibyteTest < ActiveSupport::TestCase end def test_string_should_recognize_utf8_strings - assert UTF8_STRING.is_utf8? - assert ASCII_STRING.is_utf8? - assert !EUC_JP_STRING.is_utf8? - assert !INVALID_UTF8_STRING.is_utf8? + assert_predicate UTF8_STRING, :is_utf8? + assert_predicate ASCII_STRING, :is_utf8? + assert_not_predicate EUC_JP_STRING, :is_utf8? + assert_not_predicate INVALID_UTF8_STRING, :is_utf8? end def test_mb_chars_returns_instance_of_proxy_class @@ -676,12 +676,12 @@ class OutputSafetyTest < ActiveSupport::TestCase end test "A string is unsafe by default" do - assert !@string.html_safe? + assert_not_predicate @string, :html_safe? end test "A string can be marked safe" do string = @string.html_safe - assert string.html_safe? + assert_predicate string, :html_safe? end test "Marking a string safe returns the string" do @@ -689,15 +689,15 @@ class OutputSafetyTest < ActiveSupport::TestCase end test "An integer is safe by default" do - assert 5.html_safe? + assert_predicate 5, :html_safe? end test "a float is safe by default" do - assert 5.7.html_safe? + assert_predicate 5.7, :html_safe? end test "An object is unsafe by default" do - assert !@object.html_safe? + assert_not_predicate @object, :html_safe? end test "Adding an object to a safe string returns a safe string" do @@ -705,7 +705,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string << @object assert_equal "helloother", string - assert string.html_safe? + assert_predicate string, :html_safe? end test "Adding a safe string to another safe string returns a safe string" do @@ -714,7 +714,7 @@ class OutputSafetyTest < ActiveSupport::TestCase @combination = @other_string + string assert_equal "otherhello", @combination - assert @combination.html_safe? + assert_predicate @combination, :html_safe? end test "Adding an unsafe string to a safe string escapes it and returns a safe string" do @@ -725,20 +725,20 @@ class OutputSafetyTest < ActiveSupport::TestCase assert_equal "other<foo>", @combination assert_equal "hello", @other_combination - assert @combination.html_safe? - assert !@other_combination.html_safe? + assert_predicate @combination, :html_safe? + assert_not_predicate @other_combination, :html_safe? end test "Prepending safe onto unsafe yields unsafe" do @string.prepend "other".html_safe - assert !@string.html_safe? + assert_not_predicate @string, :html_safe? assert_equal "otherhello", @string end test "Prepending unsafe onto safe yields escaped safe" do other = "other".html_safe other.prepend "" - assert other.html_safe? + assert_predicate other, :html_safe? assert_equal "<foo>other", other end @@ -747,14 +747,14 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe @other_string.concat(string) - assert !@other_string.html_safe? + assert_not_predicate @other_string, :html_safe? end test "Concatting unsafe onto safe yields escaped safe" do @other_string = "other".html_safe string = @other_string.concat("") assert_equal "other<foo>", string - assert string.html_safe? + assert_predicate string, :html_safe? end test "Concatting safe onto safe yields safe" do @@ -762,7 +762,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe @other_string.concat(string) - assert @other_string.html_safe? + assert_predicate @other_string, :html_safe? end test "Concatting safe onto unsafe with << yields unsafe" do @@ -770,14 +770,14 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe @other_string << string - assert !@other_string.html_safe? + assert_not_predicate @other_string, :html_safe? end test "Concatting unsafe onto safe with << yields escaped safe" do @other_string = "other".html_safe string = @other_string << "" assert_equal "other<foo>", string - assert string.html_safe? + assert_predicate string, :html_safe? end test "Concatting safe onto safe with << yields safe" do @@ -785,7 +785,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe @other_string << string - assert @other_string.html_safe? + assert_predicate @other_string, :html_safe? end test "Concatting safe onto unsafe with % yields unsafe" do @@ -793,7 +793,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe @other_string = @other_string % string - assert !@other_string.html_safe? + assert_not_predicate @other_string, :html_safe? end test "Concatting unsafe onto safe with % yields escaped safe" do @@ -801,7 +801,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @other_string % "" assert_equal "other<foo>", string - assert string.html_safe? + assert_predicate string, :html_safe? end test "Concatting safe onto safe with % yields safe" do @@ -809,7 +809,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe @other_string = @other_string % string - assert @other_string.html_safe? + assert_predicate @other_string, :html_safe? end test "Concatting with % doesn't modify a string" do @@ -823,7 +823,7 @@ class OutputSafetyTest < ActiveSupport::TestCase string = @string.html_safe string = string.concat(13) assert_equal "hello".dup.concat(13), string - assert string.html_safe? + assert_predicate string, :html_safe? end test "emits normal string yaml" do @@ -832,8 +832,8 @@ class OutputSafetyTest < ActiveSupport::TestCase test "call to_param returns a normal string" do string = @string.html_safe - assert string.html_safe? - assert !string.to_param.html_safe? + assert_predicate string, :html_safe? + assert_not_predicate string.to_param, :html_safe? end test "ERB::Util.html_escape should escape unsafe characters" do diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index 01cf1938be..db312685a1 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -737,7 +737,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase end def test_acts_like_time - assert Time.new.acts_like_time? + assert_predicate Time.new, :acts_like_time? end def test_formatted_offset_with_utc @@ -875,7 +875,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase # On Apr 2 2006 at 2:00AM in US, clocks were moved forward to 3:00AM. # Therefore, 2AM EST doesn't exist for this date; Time.local fails over to 3:00AM EDT assert_equal Time.local(2006, 4, 2, 3), Time.local(2006, 4, 2, 2) - assert Time.local(2006, 4, 2, 2).dst? + assert_predicate Time.local(2006, 4, 2, 2), :dst? end end diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 521b87878a..7a9561debc 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -481,7 +481,7 @@ class TimeWithZoneTest < ActiveSupport::TestCase end def test_acts_like_time - assert @twz.acts_like_time? + assert_predicate @twz, :acts_like_time? assert @twz.acts_like?(:time) assert ActiveSupport::TimeWithZone.new(DateTime.civil(2000), @time_zone).acts_like?(:time) end @@ -492,7 +492,7 @@ class TimeWithZoneTest < ActiveSupport::TestCase end def test_blank? - assert_not @twz.blank? + assert_not_predicate @twz, :blank? end def test_is_a @@ -514,10 +514,10 @@ class TimeWithZoneTest < ActiveSupport::TestCase marshal_str = Marshal.dump(@twz) mtime = Marshal.load(marshal_str) assert_equal Time.utc(2000, 1, 1, 0), mtime.utc - assert mtime.utc.utc? + assert_predicate mtime.utc, :utc? assert_equal ActiveSupport::TimeZone["Eastern Time (US & Canada)"], mtime.time_zone assert_equal Time.utc(1999, 12, 31, 19), mtime.time - assert mtime.time.utc? + assert_predicate mtime.time, :utc? assert_equal @twz.inspect, mtime.inspect end @@ -526,16 +526,16 @@ class TimeWithZoneTest < ActiveSupport::TestCase marshal_str = Marshal.dump(twz) mtime = Marshal.load(marshal_str) assert_equal Time.utc(2000, 1, 1, 0), mtime.utc - assert mtime.utc.utc? + assert_predicate mtime.utc, :utc? assert_equal "America/New_York", mtime.time_zone.name assert_equal Time.utc(1999, 12, 31, 19), mtime.time - assert mtime.time.utc? + assert_predicate mtime.time, :utc? assert_equal @twz.inspect, mtime.inspect end def test_freeze @twz.freeze - assert @twz.frozen? + assert_predicate @twz, :frozen? end def test_freeze_preloads_instance_variables -- cgit v1.2.3 From fda1863e1a8c120294c56482631d8254ad6125ff Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Thu, 25 Jan 2018 18:57:25 -0500 Subject: Remove extra whitespace --- activesupport/test/core_ext/date_time_ext_test.rb | 28 ++++++++++---------- activesupport/test/core_ext/time_ext_test.rb | 20 +++++++-------- activesupport/test/core_ext/time_with_zone_test.rb | 30 +++++++++++----------- 3 files changed, 39 insertions(+), 39 deletions(-) (limited to 'activesupport/test/core_ext') diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb index 9bd87b3c5e..894fb80cba 100644 --- a/activesupport/test/core_ext/date_time_ext_test.rb +++ b/activesupport/test/core_ext/date_time_ext_test.rb @@ -363,45 +363,45 @@ class DateTimeExtCalculationsTest < ActiveSupport::TestCase end def test_compare_with_time - assert_equal 1, DateTime.civil(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59) - assert_equal 0, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0) + assert_equal 1, DateTime.civil(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59) + assert_equal 0, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0) assert_equal(-1, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 1)) end def test_compare_with_datetime - assert_equal 1, DateTime.civil(2000) <=> DateTime.civil(1999, 12, 31, 23, 59, 59) - assert_equal 0, DateTime.civil(2000) <=> DateTime.civil(2000, 1, 1, 0, 0, 0) + assert_equal 1, DateTime.civil(2000) <=> DateTime.civil(1999, 12, 31, 23, 59, 59) + assert_equal 0, DateTime.civil(2000) <=> DateTime.civil(2000, 1, 1, 0, 0, 0) assert_equal(-1, DateTime.civil(2000) <=> DateTime.civil(2000, 1, 1, 0, 0, 1)) end def test_compare_with_time_with_zone - assert_equal 1, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]) - assert_equal 0, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["UTC"]) + assert_equal 1, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]) + assert_equal 0, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["UTC"]) assert_equal(-1, DateTime.civil(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 1), ActiveSupport::TimeZone["UTC"])) end def test_compare_with_string - assert_equal 1, DateTime.civil(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59).to_s - assert_equal 0, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0).to_s + assert_equal 1, DateTime.civil(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59).to_s + assert_equal 0, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0).to_s assert_equal(-1, DateTime.civil(2000) <=> Time.utc(2000, 1, 1, 0, 0, 1).to_s) assert_nil DateTime.civil(2000) <=> "Invalid as Time" end def test_compare_with_integer - assert_equal 1, DateTime.civil(1970, 1, 1, 12, 0, 0) <=> 2440587 - assert_equal 0, DateTime.civil(1970, 1, 1, 12, 0, 0) <=> 2440588 + assert_equal 1, DateTime.civil(1970, 1, 1, 12, 0, 0) <=> 2440587 + assert_equal 0, DateTime.civil(1970, 1, 1, 12, 0, 0) <=> 2440588 assert_equal(-1, DateTime.civil(1970, 1, 1, 12, 0, 0) <=> 2440589) end def test_compare_with_float - assert_equal 1, DateTime.civil(1970) <=> 2440586.5 - assert_equal 0, DateTime.civil(1970) <=> 2440587.5 + assert_equal 1, DateTime.civil(1970) <=> 2440586.5 + assert_equal 0, DateTime.civil(1970) <=> 2440587.5 assert_equal(-1, DateTime.civil(1970) <=> 2440588.5) end def test_compare_with_rational - assert_equal 1, DateTime.civil(1970) <=> Rational(4881173, 2) - assert_equal 0, DateTime.civil(1970) <=> Rational(4881175, 2) + assert_equal 1, DateTime.civil(1970) <=> Rational(4881173, 2) + assert_equal 0, DateTime.civil(1970) <=> Rational(4881175, 2) assert_equal(-1, DateTime.civil(1970) <=> Rational(4881177, 2)) end diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb index db312685a1..e1cb22fda8 100644 --- a/activesupport/test/core_ext/time_ext_test.rb +++ b/activesupport/test/core_ext/time_ext_test.rb @@ -756,26 +756,26 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase end def test_compare_with_time - assert_equal 1, Time.utc(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59, 999) - assert_equal 0, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0) + assert_equal 1, Time.utc(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59, 999) + assert_equal 0, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0) assert_equal(-1, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0, 001)) end def test_compare_with_datetime - assert_equal 1, Time.utc(2000) <=> DateTime.civil(1999, 12, 31, 23, 59, 59) - assert_equal 0, Time.utc(2000) <=> DateTime.civil(2000, 1, 1, 0, 0, 0) + assert_equal 1, Time.utc(2000) <=> DateTime.civil(1999, 12, 31, 23, 59, 59) + assert_equal 0, Time.utc(2000) <=> DateTime.civil(2000, 1, 1, 0, 0, 0) assert_equal(-1, Time.utc(2000) <=> DateTime.civil(2000, 1, 1, 0, 0, 1)) end def test_compare_with_time_with_zone - assert_equal 1, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]) - assert_equal 0, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["UTC"]) + assert_equal 1, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]) + assert_equal 0, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["UTC"]) assert_equal(-1, Time.utc(2000) <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 1), ActiveSupport::TimeZone["UTC"])) end def test_compare_with_string - assert_equal 1, Time.utc(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59, 999).to_s - assert_equal 0, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0).to_s + assert_equal 1, Time.utc(2000) <=> Time.utc(1999, 12, 31, 23, 59, 59, 999).to_s + assert_equal 0, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 0).to_s assert_equal(-1, Time.utc(2000) <=> Time.utc(2000, 1, 1, 0, 0, 1, 0).to_s) assert_nil Time.utc(2000) <=> "Invalid as Time" end @@ -863,11 +863,11 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase end def test_minus_with_time_with_zone - assert_equal 86_400.0, Time.utc(2000, 1, 2) - ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), ActiveSupport::TimeZone["UTC"]) + assert_equal 86_400.0, Time.utc(2000, 1, 2) - ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1), ActiveSupport::TimeZone["UTC"]) end def test_minus_with_datetime - assert_equal 86_400.0, Time.utc(2000, 1, 2) - DateTime.civil(2000, 1, 1) + assert_equal 86_400.0, Time.utc(2000, 1, 2) - DateTime.civil(2000, 1, 1) end def test_time_created_with_local_constructor_cannot_represent_times_during_hour_skipped_by_dst diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 7a9561debc..be3b8a49a9 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -221,20 +221,20 @@ class TimeWithZoneTest < ActiveSupport::TestCase end def test_compare_with_time - assert_equal 1, @twz <=> Time.utc(1999, 12, 31, 23, 59, 59) - assert_equal 0, @twz <=> Time.utc(2000, 1, 1, 0, 0, 0) + assert_equal 1, @twz <=> Time.utc(1999, 12, 31, 23, 59, 59) + assert_equal 0, @twz <=> Time.utc(2000, 1, 1, 0, 0, 0) assert_equal(-1, @twz <=> Time.utc(2000, 1, 1, 0, 0, 1)) end def test_compare_with_datetime - assert_equal 1, @twz <=> DateTime.civil(1999, 12, 31, 23, 59, 59) - assert_equal 0, @twz <=> DateTime.civil(2000, 1, 1, 0, 0, 0) + assert_equal 1, @twz <=> DateTime.civil(1999, 12, 31, 23, 59, 59) + assert_equal 0, @twz <=> DateTime.civil(2000, 1, 1, 0, 0, 0) assert_equal(-1, @twz <=> DateTime.civil(2000, 1, 1, 0, 0, 1)) end def test_compare_with_time_with_zone - assert_equal 1, @twz <=> ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]) - assert_equal 0, @twz <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["UTC"]) + assert_equal 1, @twz <=> ActiveSupport::TimeWithZone.new(Time.utc(1999, 12, 31, 23, 59, 59), ActiveSupport::TimeZone["UTC"]) + assert_equal 0, @twz <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0), ActiveSupport::TimeZone["UTC"]) assert_equal(-1, @twz <=> ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 1), ActiveSupport::TimeZone["UTC"])) end @@ -340,13 +340,13 @@ class TimeWithZoneTest < ActiveSupport::TestCase end def test_minus_with_time - assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - Time.utc(2000, 1, 1) - assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2), ActiveSupport::TimeZone["Hawaii"]) - Time.utc(2000, 1, 1) + assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - Time.utc(2000, 1, 1) + assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2), ActiveSupport::TimeZone["Hawaii"]) - Time.utc(2000, 1, 1) end def test_minus_with_time_precision - assert_equal 86_399.999999998, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["UTC"]) - Time.utc(2000, 1, 2, 0, 0, 0, Rational(1, 1000)) - assert_equal 86_399.999999998, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["Hawaii"]) - Time.utc(2000, 1, 2, 0, 0, 0, Rational(1, 1000)) + assert_equal 86_399.999999998, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["UTC"]) - Time.utc(2000, 1, 2, 0, 0, 0, Rational(1, 1000)) + assert_equal 86_399.999999998, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["Hawaii"]) - Time.utc(2000, 1, 2, 0, 0, 0, Rational(1, 1000)) end def test_minus_with_time_with_zone @@ -358,20 +358,20 @@ class TimeWithZoneTest < ActiveSupport::TestCase def test_minus_with_time_with_zone_precision twz1 = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 0, 0, 0, Rational(1, 1000)), ActiveSupport::TimeZone["UTC"]) twz2 = ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["UTC"]) - assert_equal 86_399.999999998, twz2 - twz1 + assert_equal 86_399.999999998, twz2 - twz1 end def test_minus_with_datetime - assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - DateTime.civil(2000, 1, 1) + assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - DateTime.civil(2000, 1, 1) end def test_minus_with_datetime_precision - assert_equal 86_399.999999999, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["UTC"]) - DateTime.civil(2000, 1, 1) + assert_equal 86_399.999999999, ActiveSupport::TimeWithZone.new(Time.utc(2000, 1, 1, 23, 59, 59, Rational(999999999, 1000)), ActiveSupport::TimeZone["UTC"]) - DateTime.civil(2000, 1, 1) end def test_minus_with_wrapped_datetime - assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(DateTime.civil(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - Time.utc(2000, 1, 1) - assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(DateTime.civil(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - DateTime.civil(2000, 1, 1) + assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(DateTime.civil(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - Time.utc(2000, 1, 1) + assert_equal 86_400.0, ActiveSupport::TimeWithZone.new(DateTime.civil(2000, 1, 2), ActiveSupport::TimeZone["UTC"]) - DateTime.civil(2000, 1, 1) end def test_plus_and_minus_enforce_spring_dst_rules -- cgit v1.2.3