How to stub forever?

How to stub a method for multiple calls?

The calls are done in a loop.

I expect:
@agent.stub!( :submit ).multiple_times.and_return( @account_details_page
)
…to stub submit method “forever” (any number of calls).

On 7/11/08, Piotr W. [email protected] wrote:

How to stub a method for multiple calls?

The calls are done in a loop.

I expect:
@agent.stub!( :submit ).multiple_times.and_return( @account_details_page
)
…to stub submit method “forever” (any number of calls).

Stubs will do this automatically. Just do this:

@agent.stub!( :submit ).and_return(@account_details_page)

Cheers,
David

David C. wrote:

On 7/11/08, Piotr W. [email protected] wrote:

How to stub a method for multiple calls?

The calls are done in a loop.

I expect:
@agent.stub!( :submit ).multiple_times.and_return( @account_details_page
)
…to stub submit method “forever” (any number of calls).

Stubs will do this automatically. Just do this:

@agent.stub!( :submit ).and_return(@account_details_page)

Thanks a lot.

In fact, I had a bug in my code which lead me to think stubs don’t do
that automatically.