[rspec-devel] [ rspec-Bugs-6980 ] Can't set expectations on Rails association proxy object

noreply at rubyforge.org noreply at rubyforge.org
Thu Nov 30 00:34:43 EST 2006


Bugs item #6980, was opened at 2006-11-29 22:34
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6980&group_id=797

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Pat Maddox (pergesu)
Assigned to: Nobody (None)
Summary: Can't set expectations on Rails association proxy object

Initial Comment:
edge rails, 0.7.3

context "Given a call to destroy, a Person" do
  setup do
    @person = Person.create :name => "Me", :user_id => 1
    @person.add_item Item.new(:name => "Item")
  end

  specify "should destroy its items" do
    @person.items.should_receive(:delete_all)
    @person.destroy
  end
end

This assumes the following config in Person.rb
has_many :items, :dependent => :delete_all

The failure is:
NoMethodError in 'Given a call to destroy, a Person should destroy its items'
undefined method `receive?' for Item:Class

My best guess is that since items is a proxy class defined at runtime, the should_receive method isn't getting mixed into it.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=6980&group_id=797


More information about the rspec-devel mailing list