Forum: Ruby on Rails Rspec and stubbing arrays

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C09e09e728991d8e97219de099d7dc71?d=identicon&s=25 (Guest)
on 2007-07-21 02:27
(Received via mailing list)
I'm having a little problem figuring out how to stub this scenario:

my controller has this code in it:

if current_user.foos << @foo

and my spec is giving me errors about a missing stub:

Mock 'foos' received unexpected message :<< with <TheFooObject>

Also related to this issue, I'm using mock_model but it's not pulling
in the methods from the model I've specified and I have to specify
every single stub that I want to use. Is this normal behavior?

Anyway, I also tried to do

@user = mock_model(User)

which still gave me the same dreadful error. Can anyone assist me with
my two problems?

This topic is locked and can not be replied to.