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 --- activesupport/test/concern_test.rb | 2 +- activesupport/test/configurable_test.rb | 8 ++++---- .../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 ++++++------ activesupport/test/dependencies_test.rb | 2 +- activesupport/test/multibyte_chars_test.rb | 8 ++++---- activesupport/test/ordered_options_test.rb | 6 +++--- activesupport/test/tagged_logging_test.rb | 2 +- 13 files changed, 47 insertions(+), 47 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/concern_test.rb b/activesupport/test/concern_test.rb index ef75a320d1..98d8f3ee0d 100644 --- a/activesupport/test/concern_test.rb +++ b/activesupport/test/concern_test.rb @@ -91,7 +91,7 @@ class ConcernTest < ActiveSupport::TestCase end end @klass.include test_module - assert_equal false, Object.respond_to?(:test) + assert_not_respond_to Object, :test Qux.class_eval do remove_const :ClassMethods end diff --git a/activesupport/test/configurable_test.rb b/activesupport/test/configurable_test.rb index 10719596df..1cf40261dc 100644 --- a/activesupport/test/configurable_test.rb +++ b/activesupport/test/configurable_test.rb @@ -43,11 +43,11 @@ class ConfigurableActiveSupport < ActiveSupport::TestCase test "configuration accessors are not available on instance" do instance = Parent.new - assert !instance.respond_to?(:bar) - assert !instance.respond_to?(:bar=) + assert_not_respond_to instance, :bar + assert_not_respond_to instance, :bar= - assert !instance.respond_to?(:baz) - assert !instance.respond_to?(:baz=) + assert_not_respond_to instance, :baz + assert_not_respond_to instance, :baz= end test "configuration accessors can take a default value" do 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 diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index d636da46d2..9dcd1c7200 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -752,7 +752,7 @@ class DependenciesTest < ActiveSupport::TestCase Object.const_set :C, Class.new { def self.before_remove_const; end } C.unloadable assert_called(C, :before_remove_const, times: 1) do - assert C.respond_to?(:before_remove_const) + assert_respond_to C, :before_remove_const ActiveSupport::Dependencies.clear assert !defined?(C) end diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index f51fbe2671..02934d6606 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -469,10 +469,10 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase end def test_respond_to_knows_which_methods_the_proxy_responds_to - assert "".mb_chars.respond_to?(:slice) # Defined on Chars - assert "".mb_chars.respond_to?(:capitalize!) # Defined on Chars - assert "".mb_chars.respond_to?(:gsub) # Defined on String - assert !"".mb_chars.respond_to?(:undefined_method) # Not defined + assert_respond_to "".mb_chars, :slice # Defined on Chars + assert_respond_to "".mb_chars, :capitalize! # Defined on Chars + assert_respond_to "".mb_chars, :gsub # Defined on String + assert_not_respond_to "".mb_chars, :undefined_method # Not defined end def test_method_works_for_proxyed_methods diff --git a/activesupport/test/ordered_options_test.rb b/activesupport/test/ordered_options_test.rb index 2c67bb02ac..cba5b8a8de 100644 --- a/activesupport/test/ordered_options_test.rb +++ b/activesupport/test/ordered_options_test.rb @@ -82,8 +82,8 @@ class OrderedOptionsTest < ActiveSupport::TestCase def test_introspection a = ActiveSupport::OrderedOptions.new - assert a.respond_to?(:blah) - assert a.respond_to?(:blah=) + assert_respond_to a, :blah + assert_respond_to a, :blah= assert_equal 42, a.method(:blah=).call(42) assert_equal 42, a.method(:blah).call end @@ -91,7 +91,7 @@ class OrderedOptionsTest < ActiveSupport::TestCase def test_raises_with_bang a = ActiveSupport::OrderedOptions.new a[:foo] = :bar - assert a.respond_to?(:foo!) + assert_respond_to a, :foo! assert_nothing_raised { a.foo! } assert_equal a.foo, a.foo! diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb index 5fd6a6b316..1fabd8f7a6 100644 --- a/activesupport/test/tagged_logging_test.rb +++ b/activesupport/test/tagged_logging_test.rb @@ -21,7 +21,7 @@ class TaggedLoggingTest < ActiveSupport::TestCase assert_nil logger.formatter ActiveSupport::TaggedLogging.new(logger) assert_not_nil logger.formatter - assert logger.formatter.respond_to?(:tagged) + assert_respond_to logger.formatter, :tagged end test "tagged once" do -- 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') 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 --- activesupport/test/array_inquirer_test.rb | 6 +-- activesupport/test/benchmarkable_test.rb | 2 +- .../test/cache/cache_store_logger_test.rb | 4 +- activesupport/test/cache/stores/file_store_test.rb | 4 +- activesupport/test/callback_inheritance_test.rb | 4 +- activesupport/test/class_cache_test.rb | 20 +++---- .../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 ++--- activesupport/test/deprecation_test.rb | 2 +- .../test/descendants_tracker_test_cases.rb | 2 +- .../descendants_tracker_with_autoloading_test.rb | 2 +- .../test/evented_file_update_checker_test.rb | 10 ++-- .../test/file_update_checker_shared_tests.rb | 18 +++---- activesupport/test/inflector_test.rb | 28 +++++----- activesupport/test/multibyte_chars_test.rb | 2 +- activesupport/test/safe_buffer_test.rb | 14 ++--- activesupport/test/string_inquirer_test.rb | 4 +- 26 files changed, 141 insertions(+), 141 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/array_inquirer_test.rb b/activesupport/test/array_inquirer_test.rb index d5419b862d..9a260edd8a 100644 --- a/activesupport/test/array_inquirer_test.rb +++ b/activesupport/test/array_inquirer_test.rb @@ -9,9 +9,9 @@ class ArrayInquirerTest < ActiveSupport::TestCase end def test_individual - assert @array_inquirer.mobile? - assert @array_inquirer.tablet? - assert_not @array_inquirer.desktop? + assert_predicate @array_inquirer, :mobile? + assert_predicate @array_inquirer, :tablet? + assert_not_predicate @array_inquirer, :desktop? end def test_any diff --git a/activesupport/test/benchmarkable_test.rb b/activesupport/test/benchmarkable_test.rb index 424da0a52c..497b6bac8b 100644 --- a/activesupport/test/benchmarkable_test.rb +++ b/activesupport/test/benchmarkable_test.rb @@ -26,7 +26,7 @@ class BenchmarkableTest < ActiveSupport::TestCase def test_without_block assert_raise(LocalJumpError) { benchmark } - assert buffer.empty? + assert_predicate buffer, :empty? end def test_defaults diff --git a/activesupport/test/cache/cache_store_logger_test.rb b/activesupport/test/cache/cache_store_logger_test.rb index 1af6893cc9..4648b2d361 100644 --- a/activesupport/test/cache/cache_store_logger_test.rb +++ b/activesupport/test/cache/cache_store_logger_test.rb @@ -13,7 +13,7 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase def test_logging @cache.fetch("foo") { "bar" } - assert @buffer.string.present? + assert_predicate @buffer.string, :present? end def test_log_with_string_namespace @@ -31,6 +31,6 @@ class CacheStoreLoggerTest < ActiveSupport::TestCase def test_mute_logging @cache.mute { @cache.fetch("foo") { "bar" } } - assert @buffer.string.blank? + assert_predicate @buffer.string, :blank? end end diff --git a/activesupport/test/cache/stores/file_store_test.rb b/activesupport/test/cache/stores/file_store_test.rb index 66231b0a82..eb54c47f04 100644 --- a/activesupport/test/cache/stores/file_store_test.rb +++ b/activesupport/test/cache/stores/file_store_test.rb @@ -98,13 +98,13 @@ class FileStoreTest < ActiveSupport::TestCase end assert File.exist?(cache_dir), "Parent of top level cache dir was deleted!" assert File.exist?(sub_cache_dir), "Top level cache dir was deleted!" - assert Dir.entries(sub_cache_dir).reject { |f| ActiveSupport::Cache::FileStore::EXCLUDED_DIRS.include?(f) }.empty? + assert_predicate Dir.entries(sub_cache_dir).reject { |f| ActiveSupport::Cache::FileStore::EXCLUDED_DIRS.include?(f) }, :empty? end def test_log_exception_when_cache_read_fails File.stub(:exist?, -> { raise StandardError.new("failed") }) do @cache.send(:read_entry, "winston", {}) - assert @buffer.string.present? + assert_predicate @buffer.string, :present? end end diff --git a/activesupport/test/callback_inheritance_test.rb b/activesupport/test/callback_inheritance_test.rb index 67813a749e..015e17deb9 100644 --- a/activesupport/test/callback_inheritance_test.rb +++ b/activesupport/test/callback_inheritance_test.rb @@ -164,10 +164,10 @@ end class DynamicInheritedCallbacks < ActiveSupport::TestCase def test_callbacks_looks_to_the_superclass_before_running child = EmptyChild.new.dispatch - assert !child.performed? + assert_not_predicate child, :performed? EmptyParent.set_callback :dispatch, :before, :perform! child = EmptyChild.new.dispatch - assert child.performed? + assert_predicate child, :performed? end def test_callbacks_should_be_performed_once_in_child_class diff --git a/activesupport/test/class_cache_test.rb b/activesupport/test/class_cache_test.rb index 7b97028e8c..c9c979b2f6 100644 --- a/activesupport/test/class_cache_test.rb +++ b/activesupport/test/class_cache_test.rb @@ -11,17 +11,17 @@ module ActiveSupport end def test_empty? - assert @cache.empty? + assert_predicate @cache, :empty? @cache.store(ClassCacheTest) - assert !@cache.empty? + assert_not_predicate @cache, :empty? end def test_clear! - assert @cache.empty? + assert_predicate @cache, :empty? @cache.store(ClassCacheTest) - assert !@cache.empty? + assert_not_predicate @cache, :empty? @cache.clear! - assert @cache.empty? + assert_predicate @cache, :empty? end def test_set_key @@ -40,29 +40,29 @@ module ActiveSupport end def test_get_constantizes - assert @cache.empty? + assert_predicate @cache, :empty? assert_equal ClassCacheTest, @cache.get(ClassCacheTest.name) end def test_get_constantizes_fails_on_invalid_names - assert @cache.empty? + assert_predicate @cache, :empty? assert_raise NameError do @cache.get("OmgTotallyInvalidConstantName") end end def test_get_alias - assert @cache.empty? + assert_predicate @cache, :empty? assert_equal @cache[ClassCacheTest.name], @cache.get(ClassCacheTest.name) end def test_safe_get_constantizes - assert @cache.empty? + assert_predicate @cache, :empty? assert_equal ClassCacheTest, @cache.safe_get(ClassCacheTest.name) end def test_safe_get_constantizes_doesnt_fail_on_invalid_names - assert @cache.empty? + assert_predicate @cache, :empty? assert_nil @cache.safe_get("OmgTotallyInvalidConstantName") end 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 diff --git a/activesupport/test/deprecation_test.rb b/activesupport/test/deprecation_test.rb index f2267a822f..c61761901b 100644 --- a/activesupport/test/deprecation_test.rb +++ b/activesupport/test/deprecation_test.rb @@ -158,7 +158,7 @@ class DeprecationTest < ActiveSupport::TestCase stderr_output = capture(:stderr) { assert_nil behavior.call("Some error!", ["call stack!"], "horizon", "gem") } - assert stderr_output.empty? + assert_predicate stderr_output, :empty? end def test_default_notify_behavior diff --git a/activesupport/test/descendants_tracker_test_cases.rb b/activesupport/test/descendants_tracker_test_cases.rb index 1f8b4a8605..fd860f74da 100644 --- a/activesupport/test/descendants_tracker_test_cases.rb +++ b/activesupport/test/descendants_tracker_test_cases.rb @@ -37,7 +37,7 @@ module DescendantsTrackerTestCases mark_as_autoloaded(*ALL) do ActiveSupport::DescendantsTracker.clear ALL.each do |k| - assert ActiveSupport::DescendantsTracker.descendants(k).empty? + assert_predicate ActiveSupport::DescendantsTracker.descendants(k), :empty? end end end diff --git a/activesupport/test/descendants_tracker_with_autoloading_test.rb b/activesupport/test/descendants_tracker_with_autoloading_test.rb index 7c396b7c8e..10efbfbb8c 100644 --- a/activesupport/test/descendants_tracker_with_autoloading_test.rb +++ b/activesupport/test/descendants_tracker_with_autoloading_test.rb @@ -12,7 +12,7 @@ class DescendantsTrackerWithAutoloadingTest < ActiveSupport::TestCase mark_as_autoloaded(*ALL) do ActiveSupport::DescendantsTracker.clear ALL.each do |k| - assert ActiveSupport::DescendantsTracker.descendants(k).empty? + assert_predicate ActiveSupport::DescendantsTracker.descendants(k), :empty? end end end diff --git a/activesupport/test/evented_file_update_checker_test.rb b/activesupport/test/evented_file_update_checker_test.rb index 9b560f7f42..d3af0dbef3 100644 --- a/activesupport/test/evented_file_update_checker_test.rb +++ b/activesupport/test/evented_file_update_checker_test.rb @@ -39,18 +39,18 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase FileUtils.touch(tmpfiles) checker = new_checker(tmpfiles) {} - assert !checker.updated? + assert_not_predicate checker, :updated? # Pipes used for flow control across fork. boot_reader, boot_writer = IO.pipe touch_reader, touch_writer = IO.pipe pid = fork do - assert checker.updated? + assert_predicate checker, :updated? # Clear previous check value. checker.execute - assert !checker.updated? + assert_not_predicate checker, :updated? # Fork is booted, ready for file to be touched # notify parent process. @@ -60,7 +60,7 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase # has been touched. IO.select([touch_reader]) - assert checker.updated? + assert_predicate checker, :updated? end assert pid @@ -72,7 +72,7 @@ class EventedFileUpdateCheckerTest < ActiveSupport::TestCase # Notify fork that files have been touched. touch_writer.write("touched") - assert checker.updated? + assert_predicate checker, :updated? Process.wait(pid) end diff --git a/activesupport/test/file_update_checker_shared_tests.rb b/activesupport/test/file_update_checker_shared_tests.rb index f8266dac06..daf7f9d139 100644 --- a/activesupport/test/file_update_checker_shared_tests.rb +++ b/activesupport/test/file_update_checker_shared_tests.rb @@ -89,12 +89,12 @@ module FileUpdateCheckerSharedTests i = 0 checker = new_checker(tmpfiles) { i += 1 } - assert !checker.updated? + assert_not_predicate checker, :updated? touch(tmpfiles) wait - assert checker.updated? + assert_predicate checker, :updated? end test "updated should become true when watched files are modified" do @@ -103,12 +103,12 @@ module FileUpdateCheckerSharedTests FileUtils.touch(tmpfiles) checker = new_checker(tmpfiles) { i += 1 } - assert !checker.updated? + assert_not_predicate checker, :updated? touch(tmpfiles) wait - assert checker.updated? + assert_predicate checker, :updated? end test "updated should become true when watched files are deleted" do @@ -117,12 +117,12 @@ module FileUpdateCheckerSharedTests FileUtils.touch(tmpfiles) checker = new_checker(tmpfiles) { i += 1 } - assert !checker.updated? + assert_not_predicate checker, :updated? rm_f(tmpfiles) wait - assert checker.updated? + assert_predicate checker, :updated? end test "should be robust to handle files with wrong modified time" do @@ -164,14 +164,14 @@ module FileUpdateCheckerSharedTests i = 0 checker = new_checker(tmpfiles) { i += 1 } - assert !checker.updated? + assert_not_predicate checker, :updated? touch(tmpfiles) wait - assert checker.updated? + assert_predicate checker, :updated? checker.execute - assert !checker.updated? + assert_not_predicate checker, :updated? end test "should execute the block if files change in a watched directory one extension" do diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 0e3e576a70..4c15d54af4 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -460,12 +460,12 @@ class InflectorTest < ActiveSupport::TestCase ActiveSupport::Inflector.inflections(:es) { |inflect| inflect.clear } - assert ActiveSupport::Inflector.inflections(:es).plurals.empty? - assert ActiveSupport::Inflector.inflections(:es).singulars.empty? - assert ActiveSupport::Inflector.inflections(:es).uncountables.empty? - assert !ActiveSupport::Inflector.inflections.plurals.empty? - assert !ActiveSupport::Inflector.inflections.singulars.empty? - assert !ActiveSupport::Inflector.inflections.uncountables.empty? + assert_predicate ActiveSupport::Inflector.inflections(:es).plurals, :empty? + assert_predicate ActiveSupport::Inflector.inflections(:es).singulars, :empty? + assert_predicate ActiveSupport::Inflector.inflections(:es).uncountables, :empty? + assert_not_predicate ActiveSupport::Inflector.inflections.plurals, :empty? + assert_not_predicate ActiveSupport::Inflector.inflections.singulars, :empty? + assert_not_predicate ActiveSupport::Inflector.inflections.uncountables, :empty? end def test_clear_all @@ -478,10 +478,10 @@ class InflectorTest < ActiveSupport::TestCase inflect.clear :all - assert inflect.plurals.empty? - assert inflect.singulars.empty? - assert inflect.uncountables.empty? - assert inflect.humans.empty? + assert_predicate inflect.plurals, :empty? + assert_predicate inflect.singulars, :empty? + assert_predicate inflect.uncountables, :empty? + assert_predicate inflect.humans, :empty? end end @@ -495,10 +495,10 @@ class InflectorTest < ActiveSupport::TestCase inflect.clear - assert inflect.plurals.empty? - assert inflect.singulars.empty? - assert inflect.uncountables.empty? - assert inflect.humans.empty? + assert_predicate inflect.plurals, :empty? + assert_predicate inflect.singulars, :empty? + assert_predicate inflect.uncountables, :empty? + assert_predicate inflect.humans, :empty? end end diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index 02934d6606..560b86b1a3 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -485,7 +485,7 @@ class MultibyteCharsUTF8BehaviourTest < ActiveSupport::TestCase end def test_acts_like_string - assert "Bambi".mb_chars.acts_like_string? + assert_predicate "Bambi".mb_chars, :acts_like_string? end end diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb index 05c2fb59be..1c19c92bb0 100644 --- a/activesupport/test/safe_buffer_test.rb +++ b/activesupport/test/safe_buffer_test.rb @@ -39,7 +39,7 @@ class SafeBufferTest < ActiveSupport::TestCase end test "Should be considered safe" do - assert @buffer.html_safe? + assert_predicate @buffer, :html_safe? end test "Should return a safe buffer when calling to_s" do @@ -78,13 +78,13 @@ class SafeBufferTest < ActiveSupport::TestCase test "Should not return safe buffer from gsub" do altered_buffer = @buffer.gsub("", "asdf") assert_equal "asdf", altered_buffer - assert !altered_buffer.html_safe? + assert_not_predicate altered_buffer, :html_safe? end test "Should not return safe buffer from gsub!" do @buffer.gsub!("", "asdf") assert_equal "asdf", @buffer - assert !@buffer.html_safe? + assert_not_predicate @buffer, :html_safe? end test "Should escape dirty buffers on add" do @@ -101,13 +101,13 @@ class SafeBufferTest < ActiveSupport::TestCase test "Should preserve html_safe? status on copy" do @buffer.gsub!("", "<>") - assert !@buffer.dup.html_safe? + assert_not_predicate @buffer.dup, :html_safe? end test "Should return safe buffer when added with another safe buffer" do clean = "