[rspec-users] chain argument expectations?

Chuck Remes cremes.devlist at mac.com
Fri Jun 18 12:24:42 EDT 2010


On Jun 17, 2010, at 12:22 PM, David Chelimsky wrote:

> On Jun 17, 2010, at 11:07 AM, Chuck Remes wrote:
> 
>> it "should assign increasing index values to field3" do
>> quxxo = mock
>> Baz.stub!(:new => quxxo)
>> 
>> quxxo.should_receive(:field2=).with(1,2,3)
>> end
>> 
>> This doesn't work. I tried a few different variants.
>> 
>> quxxo.should_receive(:field2=).with(1).with(2).with(3)
>> 
>> that doesn't work either.
>> 
>> Any suggestions on how to set expectations for a single mock to receive the same message multiple time with different arguments with the express purpose of validating the arguments?
> 
> quxxo.stub(:field2=)
> quxxo.should_receive(:field2=).with(1)
> quxxo.should_receive(:field2=).with(2)
> quxxo.should_receive(:field2=).with(3)

Ah, so obvious in retrospect. Many thanks...

cr



More information about the rspec-users mailing list