[rspec-users] Trouble using should_receive

Glenn Ford glenn at aldenta.com
Thu Nov 15 13:50:34 EST 2007


I have this code trying to ensure my reset method works.  I want to  
make sure all the participants have their destroy method called.

# in my spec for Room
     r = Room.new(:name => 'bob')
     r.save

     p = Participant.new(:login => 'a', :password =>  
'b', :password_confirmation => 'b')
     p.room = r
     p.save!
     p.should_receive(:destroy)

     r.reset

#in room.rb
   def reset
     participants.each { |p| p.destroy }
     save!
   end

Unfortunately it fails.  I print out "p" in both locations and while  
they have all the same data, they have different memory addresses.  I  
don't know if this is the explanation for the issue but it's all I can  
find so far.

How do I fix this?  Thanks!

Glenn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071115/e5bee540/attachment.html 


More information about the rspec-users mailing list