# Rspec and stubbing arrays

**URL:** <https://www.ruby-forum.com/t/rspec-and-stubbing-arrays/110004>\
**Category:** Rails\
**Created:** [July 21, 2007, 2:27am UTC](https://www.ruby-forum.com/t/rspec-and-stubbing-arrays/110004 "2007-07-21T02:27:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [July 21, 2007, 2:27am UTC](https://www.ruby-forum.com/t/rspec-and-stubbing-arrays/110004/1 "2007-07-21T02:27:32Z")

</div>

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

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)  
@user.foos.stub!(:\<\<).and\_return([])

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

TIA  
-L
