Mock should_receive for multiple calls in one declaration?

100 views
Skip to first unread message

Pito Salas

unread,
Feb 22, 2013, 7:54:48 PM2/22/13
to rs...@googlegroups.com
I have this:

pserv = double("ProgramServices")
pserv.should_receive(:smart_add_participant).with(any_args()).exactly(2).times

But what I would like to say is that when :smart_add_participant is called each time the arguments are, respectively:

smart_add_participant("A", 2, 3) # first time
smart_add_participant("A", 4, 1) # second time

Is there a way to to express that?

Thank you!



David Chelimsky

unread,
Feb 22, 2013, 8:02:05 PM2/22/13
to rs...@googlegroups.com
pserv.should_receive(:smart_add_participant).with("A", 2, 3)
pserv.should_receive(:smart_add_participant).with("A", 4, 1)

And if order matters:

pserv.should_receive(:smart_add_participant).with("A", 2, 3).ordered
pserv.should_receive(:smart_add_participant).with("A", 4, 1).ordered

Cheers,
David

>
> Thank you!
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "rspec" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rspec+un...@googlegroups.com.
> To post to this group, send email to rs...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/rspec/-/HugZowISE4gJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Pito Salas

unread,
Feb 22, 2013, 8:39:59 PM2/22/13
to rs...@googlegroups.com
what could be simpler? Thanks!

dchel...@gmail.com

unread,
Feb 23, 2013, 12:16:04 PM2/23/13
to rs...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages