[rspec-users] [RSpec] Error when returning multiple values from a stub

Nick Hoffman nick at deadorange.com
Tue Jan 27 11:03:53 EST 2009

Hey guys. I've just found some odd behaviour within RSpec 1.1.12 , and  
would like to know whether this is a bug, or I'm doing something wrong.

When I give multiple return values to a stub, like this:
   SubtitleFile.stub!(:new).and_return @sf1, @sf2
RSpec complains:
   Mock 'SubtitleFile_1001' received unexpected message :size with (no  

However, if I break that into two stubs, like this:
   SubtitleFile.stub!(:new).and_return @sf1
   SubtitleFile.stub!(:new).and_return @sf2
the spec passes.

I've posted a more concrete example here:

In code pane #2, if I comment line 13 and uncomment lines 14 and 15,  
the spec passes.

Any idea what's going on? Thanks for your help,

More information about the rspec-users mailing list