[rspec-users] unexpected should_receive behaviour

Ben Lovell benjamin.lovell at gmail.com
Tue Oct 9 12:49:16 UTC 2012


Hi,

On 9 October 2012 13:04, enrico stano <enricostn at gmail.com> wrote:

> Hi,
>
> surely I'm missing something... but what!?
>
> in my spec I've
>
> User.should_receive(:find).with("1").and_return(@user)
>
> and in my controller
>
> User.find(params[:id])
>
> green light... correct...
>
> but if I change my controller using another method, for example first:
>
> User.first
>
> or even
>
> User.all
>
> I get green light too... I was expecting an error like
>
> expected: 1 time
> received: 0 times
>
> could anyone give me a hint to understand that behaviour?
>


There is something wrong with your spec or your spec's setup. Could you
post a gist of the spec and the controller action?

Regards,
Ben


>
> I've opened a question on StackOverflow too:
>
> http://stackoverflow.com/questions/12799617/unexpected-rspec-should-receive-behaviour
>
> many thanks,
>
> enricostn
>
> --
> · Enrico Stano
> ·
> · twitter @enricostano
> · skype ocirneonats
> _
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20121009/1311722a/attachment.html>


More information about the rspec-users mailing list