[rspec-users] should_receive.again

aslak hellesoy aslak.hellesoy at gmail.com
Sun Jun 3 06:21:18 EDT 2007


On 6/3/07, Jonathan Linowes <jonathan at parkerhill.com> wrote:
> Hi,
>
> It appears that if I have 2 should_receives in a row, the latest one
> overrides the previous one(s).
>
> If there isn't one, could we add a way to accumulate them, such as
>
> @thing.should_receive(:method).and_return(@value)
> @thing.should_receive(:method).again.and_return(@value)
> @thing.should_receive(:method).again.and_return(@value)
>
> would be equivalent to
>
> @thing.should_receive(:method).times(3).and_return(@value)
>
> This would be helpful because I have a setup method that sets up the
> should_receive once, and then some specific actions may use that
> method one or more additional times.
>

@thing.should_receive(:method).exactly(3).times.and_return(@value)
http://rspec.rubyforge.org/rdoc/classes/Spec/Mocks.html

Aslak

> thanks
> linoj
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list