[rspec-users] should_receive twice and arguments

Ivo Dancet ivo.dancet at gmail.com
Sun Jan 13 09:05:32 EST 2008


Ok,

found the problem after trying to make an example: I forgot to add a  
stub! to accept the second call to create!

I didn't find it sooner because the error was:

Mock 'Class' expected :create! with ({:name=>"foo"}) but received it  
with ({:name=>"foo2"})
And it did get it with ({:name => "foo"}), but only the first time...

Thanks!
Ivo



Op 13-jan-08, om 14:00 heeft David Chelimsky het volgende geschreven:

> On Jan 13, 2008 6:56 AM, Ivo Dancet <ivo.dancet at gmail.com> wrote:
>> Hi all, I have a method calling Klass.create! two times with  
>> different
>> arguments (this happens in a class reponsable for reading in a csv  
>> file)
>>
>> I want to test those like this:
>>
>> in one test: Klass.should_receive(:create!).with(:name => "foo").once
>> in another: Klass.should_receive(:create!).with(:name => "foo2").once
>>
>> This doesn't work because the 'once' is only about the create! call,
>
> Actually, that should work. 'once' is about the complete expectation
> including the arguments. If this isn't working you've uncovered a bug.
> Please report it to the lighthouse (http://rspec.lighthouseapp.com)
> with specific examples we can run and the output you're getting.
>
> Thanks,
> David
>
>> it doesn't use the arguments to make the call unique. Can I make this
>> work another way (not only should_receive(:create!).twice, I want to
>> test the arguments).
>>
>> Thanks for any feedback.
>>
>> Ivo
>>
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list