This project is archived and is in readonly mode.

#4644 ✓invalid
Neeraj Singh

Use assert_respond_to because it has better error messaging

Reported by Neeraj Singh | May 18th, 2010 @ 05:25 PM | in 3.x

Patch will be attached through comment.

Comments and changes to this ticket

  • Neeraj Singh

    Neeraj Singh May 18th, 2010 @ 05:30 PM

    • Tag changed from rails3, test to patch, rails3, test
    • Assigned user set to “José Valim”
  • Santiago Pastorino

    Santiago Pastorino May 18th, 2010 @ 11:11 PM

    • Milestone set to 3.x
    • State changed from “new” to “verified”

    The patch is ok Neeraj but please do this on the rails top dir:
    $ grep -r 'assert ' * | grep respond_to and change all the uses

    i get all this files waiting for your change ...

    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:new_any_old_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:createany_old_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:deliverany_old_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:create_Any_old_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:deliver_Any_old_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:create_1_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:deliver_1_template)
    actionmailer/test/old_base/mail_service_test.rb: assert !RespondToMailer.respond_to?(:foo_deliver_template)
    actionmailer/test/base_test.rb: assert !BaseMailer.respond_to?(:mail)
    actionmailer/test/base_test.rb: assert !BaseMailer.respond_to?(:headers)
    actionpack/test/controller/url_for_test.rb: assert controller.respond_to?(:home_url)
    actionpack/test/controller/url_for_test.rb: assert controller.respond_to?(:home_url)
    actionpack/test/abstract/collector_test.rb: assert !collector.respond_to?(:unknown)
    actionpack/test/abstract/collector_test.rb: assert !collector.respond_to?(:js)
    activemodel/test/cases/callbacks_test.rb: assert !ModelCallbacks.respond_to?(:before_initialize)
    activemodel/test/cases/callbacks_test.rb: assert !ModelCallbacks.respond_to?(:around_initialize)
    activemodel/test/cases/attribute_methods_test.rb: assert !ModelWithAttributes.new.respond_to?(:foo)
    activemodel/lib/active_model/lint.rb: assert model.respond_to?(:to_key), "The model should respond to to_key"
    activemodel/lib/active_model/lint.rb: assert model.respond_to?(:to_param), "The model should respond to to_param"
    activemodel/lib/active_model/lint.rb: assert model.respond_to?(:valid?), "The model should respond to valid?"
    activemodel/lib/active_model/lint.rb: assert model.respond_to?(:persisted?), "The model should respond to persisted?"
    activemodel/lib/active_model/lint.rb: assert model.class.respond_to?(:model_name), "The model should respond to model_name"
    activemodel/lib/active_model/lint.rb: assert model.respond_to?(:errors), "The model should respond to errors"
    activemodel/lib/active_model/lint.rb: assert model.respond_to?(:errors), "The model should respond to errors"
    activemodel/lib/active_model/lint.rb: assert @model.respond_to?(:to_model), "The object should respond_to to_model"
    activerecord/test/cases/finder_test.rb: #assert !topic.respond_to?("title")
    activerecord/test/cases/finder_test.rb: assert topic.respond_to?("author_name")
    activerecord/test/cases/named_scope_test.rb: assert Topic.approved.respond_to?(:limit)
    activerecord/test/cases/named_scope_test.rb: assert Topic.approved.respond_to?(:count)
    activerecord/test/cases/named_scope_test.rb: assert Topic.approved.respond_to?(:length)
    activerecord/test/cases/named_scope_test.rb: assert !Topic.approved.respond_to?(:with_create_scope)
    activerecord/test/cases/named_scope_test.rb: assert Topic.approved.respond_to?(:with_create_scope, true)
    activerecord/test/cases/named_scope_test.rb: assert Topic.respond_to?(reserved_method, true)
    activerecord/test/cases/relations_test.rb: assert relation.respond_to?(method), "Topic.scoped should respond to #{method.inspect}"
    activerecord/test/cases/relations_test.rb: assert ! relation.respond_to?(:matching_attributes)
    activerecord/test/cases/relations_test.rb: assert relation.respond_to?(:matching_attributes, true)
    activerecord/test/cases/relations_test.rb: assert relation.respond_to?(method), "Topic.scoped should respond to #{method.inspect}"
    activerecord/test/cases/relations_test.rb: assert DeveloperOrderedBySalary.scoped.respond_to?(:all_ordered_by_name)
    activerecord/test/cases/relations_test.rb: assert Topic.scoped.respond_to?(:by_lifo)
    activerecord/test/cases/autosave_association_test.rb: assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_ship)
    activerecord/test/cases/autosave_association_test.rb: assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrot)
    activerecord/test/cases/autosave_association_test.rb: assert !@pirate.respond_to?(:validate_associated_records_for_non_validated_parrots)
    activerecord/test/cases/base_test.rb: assert !topic.respond_to?("nothingness")
    activerecord/test/cases/base_test.rb: assert !topic.respond_to?(:nothingness)
    activerecord/test/cases/base_test.rb: assert !topic.respond_to?("mumbo")
    activerecord/test/cases/base_test.rb: assert !Task.new.respond_to?("#{method}=")
    activerecord/test/cases/xml_serialization_test.rb: assert !authors(:david).hello_posts.first.respond_to?(:label)
    activerecord/test/cases/associations/has_many_associations_test.rb: assert !client_association.respond_to?(:private_method)
    activerecord/test/cases/associations/has_many_associations_test.rb: assert client_association.respond_to?(:private_method, true)
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("name")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("name=")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("name?")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("joined_on")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: #assert project.respond_to?("joined_on=")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("joined_on?")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("access_level")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: #assert project.respond_to?("access_level=")
    activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb: assert project.respond_to?("access_level?")
    activerecord/test/cases/attribute_methods_test.rb: assert topic.respond_to?('title')
    activerecord/test/cases/attribute_methods_test.rb: assert !topic.respond_to?('title_hello_world')
    activerecord/test/cases/attribute_methods_test.rb: assert topic.respond_to?(meth)
    activerecord/test/cases/attribute_methods_test.rb: assert topic.respond_to?(meth)
    activerecord/test/cases/attribute_methods_test.rb: assert topic.respond_to?(meth)
    activerecord/test/cases/attribute_methods_test.rb: assert !topic.respond_to?(:title)
    activerecord/test/cases/attribute_methods_test.rb: assert !topic.respond_to?(:title=)
    activerecord/test/cases/attribute_methods_test.rb: assert !topic.respond_to?(:title?)
    activerecord/test/cases/json_serialization_test.rb: assert !@david.posts.first.respond_to?(:favorite_quote)
    activerecord/test/cases/finder_respond_to_test.rb: assert !Topic.respond_to?(:find_by_undertitle)
    activerecord/test/cases/finder_respond_to_test.rb: assert !Topic.respond_to?(:fail_to_find_by_title)
    activerecord/test/cases/finder_respond_to_test.rb: assert !Topic.respond_to?(:find_by_title?)
    activerecord/test/cases/finder_respond_to_test.rb: assert !Topic.respond_to?(:fail_to_find_or_create_by_title)
    activerecord/test/cases/finder_respond_to_test.rb: assert !Topic.respond_to?(:find_or_create_by_title?)
    activeresource/test/cases/base/schema_test.rb: assert Person.new.respond_to?(col.to_s), "should respond to the schema's string key, but failed on: #{col.to_s}"
    activeresource/test/cases/base/schema_test.rb: assert Person.new.respond_to?(col.to_sym), "should respond to the schema's symbol key, but failed on: #{col.to_sym}"
    activeresource/test/cases/base/schema_test.rb: assert Person.respond_to?(:schema), "should at least respond to the schema method"
    activeresource/test/cases/base/schema_test.rb: assert s.respond_to?(:attrs), "should return attributes in theory"
    activeresource/test/cases/base/schema_test.rb: assert !self.respond_to?(bad_value), "should only respond to a known attribute type, but accepted: #{bad_value.inspect}"
    activeresource/test/cases/base/schema_test.rb: assert Person.new.respond_to?(new_attr_name), "should respond to the attribute in a passed-in schema, but failed on: #{new_attr_name}"
    activeresource/test/cases/base/schema_test.rb: assert Person.new.respond_to?(new_attr_name_two), "should respond to the attribute from the schema, but failed on: #{new_attr_name_two}"
    activeresource/test/cases/base/schema_test.rb: assert Person.new.respond_to?(new_attr_name), "should respond to the attribute in a passed-in schema, but failed on: #{new_attr_name}"
    activeresource/test/cases/base/schema_test.rb: assert Person.new.respond_to?(new_attr_name_two), "should respond to the attribute from the schema, but failed on: #{new_attr_name_two}"
    activeresource/test/cases/base_test.rb: assert matz.respond_to?(:name)
    activeresource/test/cases/base_test.rb: assert matz.respond_to?(:name=)
    activeresource/test/cases/base_test.rb: assert matz.respond_to?(:name?)
    activeresource/test/cases/base_test.rb: assert !matz.respond_to?(:super_scalable_stuff)
    activesupport/test/core_ext/object_and_class_ext_test.rb: assert !@string.respond_to?(method)
    activesupport/test/core_ext/class/attribute_accessor_test.rb: assert @class.respond_to?(:foo)
    activesupport/test/core_ext/class/attribute_accessor_test.rb: assert @class.respond_to?(:foo=)
    activesupport/test/core_ext/class/attribute_accessor_test.rb: assert @object.respond_to?(:bar)
    activesupport/test/core_ext/class/attribute_accessor_test.rb: assert !@object.respond_to?(:bar=)
    activesupport/test/core_ext/class/attribute_accessor_test.rb: assert @class.respond_to?(:shaq)
    activesupport/test/core_ext/class/attribute_accessor_test.rb: assert !@object.respond_to?(:shaq)
    activesupport/test/core_ext/class/class_inheritable_attributes_test.rb: assert !@klass.new.respond_to?(:a=)
    activesupport/test/core_ext/class/class_inheritable_attributes_test.rb: assert !@klass.new.respond_to?(:a=)
    activesupport/test/core_ext/class/class_inheritable_attributes_test.rb: assert !@klass.new.respond_to?(:a=)
    activesupport/test/core_ext/class/class_inheritable_attributes_test.rb: assert !@klass.new.respond_to?(:a=)
    activesupport/test/core_ext/class/delegating_attributes_test.rb: assert single_class.respond_to?(:both)
    activesupport/test/core_ext/class/delegating_attributes_test.rb: assert single_class.respond_to?(:both=)
    activesupport/test/core_ext/class/delegating_attributes_test.rb: assert single_class.respond_to?(:no_instance_reader)
    activesupport/test/core_ext/class/delegating_attributes_test.rb: assert single_class.respond_to?(:no_instance_reader=)
    activesupport/test/core_ext/module_test.rb: assert @instance.respond_to?(:bar)
    activesupport/test/core_ext/module_test.rb: assert !@instance.respond_to?(method)
    activesupport/test/core_ext/module_test.rb: assert @instance.respond_to?(method)
    activesupport/test/core_ext/module_test.rb: assert !@instance.respond_to?(:quux_with_baz!)
    activesupport/test/core_ext/module_test.rb: assert @instance.respond_to?(:quux_with_baz!)
    activesupport/test/core_ext/module_test.rb: assert !@instance.respond_to?(:quux_with_baz!)
    activesupport/test/core_ext/module_test.rb: assert !@instance.respond_to?(:quux_with_baz?)
    activesupport/test/core_ext/module_test.rb: assert !@instance.respond_to?(:quux_with_baz=)
    activesupport/test/core_ext/module_test.rb: assert @instance.respond_to?(:quux_with_baz!)
    activesupport/test/core_ext/module_test.rb: assert @instance.respond_to?(:quux_with_baz?)
    activesupport/test/core_ext/module_test.rb: assert @instance.respond_to?(:quux_with_baz=)
    activesupport/test/core_ext/module/synchronization_test.rb: assert @instance.respond_to?(:value_with_synchronization)
    activesupport/test/core_ext/module/synchronization_test.rb: assert @instance.respond_to?(:value_without_synchronization)
    activesupport/test/core_ext/module/synchronization_test.rb: assert @target.respond_to?(:to_s_without_synchronization)
    activesupport/test/core_ext/module/attribute_accessor_test.rb: assert @module.respond_to?(:foo)
    activesupport/test/core_ext/module/attribute_accessor_test.rb: assert @module.respond_to?(:foo=)
    activesupport/test/core_ext/module/attribute_accessor_test.rb: assert @object.respond_to?(:bar)
    activesupport/test/core_ext/module/attribute_accessor_test.rb: assert !@object.respond_to?(:bar=)
    activesupport/test/core_ext/module/attribute_accessor_test.rb: assert @module.respond_to?(:shaq)
    activesupport/test/core_ext/module/attribute_accessor_test.rb: assert !@object.respond_to?(:shaq)
    activesupport/test/core_ext/string_ext_test.rb: assert UNICODE_STRING.respond_to?(:mb_chars)
    activesupport/test/dependencies_test.rb: assert !Module.new.respond_to?(:const_missing_without_dependencies)
    activesupport/test/dependencies_test.rb: assert !Module.new.respond_to?(:load_without_new_constant_marking)
    activesupport/test/multibyte_chars_test.rb: assert ''.mb_chars.respond_to?(:slice) # Defined on Chars
    activesupport/test/multibyte_chars_test.rb: assert ''.mb_chars.respond_to?(:capitalize!) # Defined on Chars
    activesupport/test/multibyte_chars_test.rb: assert ''.mb_chars.respond_to?(:gsub) # Defined on String
    activesupport/test/multibyte_chars_test.rb: assert !''.mb_chars.respond_to?(:undefined_method) # Not defined
    activesupport/test/time_zone_test.rb: assert zone.tzinfo.respond_to?(:period_for_local)
    railties/test/railties/engine_test.rb: assert !Rails::Engine.respond_to?(:config)
    railties/test/railties/plugin_test.rb: assert !Rails::Plugin.respond_to?(:config)
    railties/test/railties/railtie_test.rb: assert !Rails::Railtie.respond_to?(:config)
    railties/test/application/console_test.rb: assert User.new.respond_to?(:name)
    railties/test/application/console_test.rb: assert !User.new.respond_to?(:age)
    railties/test/application/console_test.rb: assert !User.new.respond_to?(:age)
    railties/test/application/console_test.rb: assert User.new.respond_to?(:age)

  • Neeraj Singh

    Neeraj Singh May 19th, 2010 @ 02:37 AM

    Attached is revised patch.

    I am going through all the test files one by one. I am not doing any grep and trying to change something specific. If needed these three tickets 4644 4643 4645 can be combined into one commit.

    Reason I kept them separate was, I was not sure what changes would appeal core team and what not.

  • Neeraj Singh

    Neeraj Singh May 19th, 2010 @ 02:52 AM

    This ticket can be closed. I am providing patch through #4645 .

  • José Valim

    José Valim June 7th, 2010 @ 09:37 AM

    • State changed from “verified” to “invalid”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages