#122 new
Chad Humphries

[#14391] .should respond_to() vs respond_to?()

Reported by Chad Humphries | November 19th, 2007 @ 06:33 AM

In Rails, when methods are declared on an association such as a has_many, these methods are not visible to the respond_to() rSpec method.

for example:

class Item < ActiveRecord::Base
has_many :translations do
    def active
        find(:first, :conditions => {:language_id, Language.active.id})
    end
end
end
it "should add an active method to the translations association" do
  @item.translations.should respond_to(:active)
end

^^ will never pass, however

it "should add an active method to the translations association" do
  @item.translations.respond_to?(:active).should be_true
end

^^ will pass

Comments and changes to this ticket

  • Chad Humphries

    Chad Humphries November 19th, 2007 @ 06:33 AM

    Date: 2007-10-02 18:09

    Sender: Garrett Heaver

    If you think it belongs better as that David, absolutly.

    I'm going to try and dig into it a bit myself but someone who

    knows the matcher

    better might well beat me to it.

    Date: 2007-10-02 18:05

    Sender: David Chelimsky

    This strikes me as a bug rather than a feature request - agree?

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

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

Behaviour Driven Development for Ruby.

Shared Ticket Bins

People watching this ticket