[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Mocha: expects any number of time

Fernando Perez

4/17/2009 4:05:00 PM

Hi,

How to create an assertion that only checks that a given method is
invoked at least once.

In my Rails app I wanted to mock current_user, but I don't care how many
times it gets called, but I want to make sure it is called, so:

@controller.expects(:current_user).returns(@user)

doesn't work, because for instance it tells it was already invoked once.


Thanks.
--
Posted via http://www.ruby-....

1 Answer

Ben Lovell

4/17/2009 4:28:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

On Fri, Apr 17, 2009 at 5:05 PM, Fernando Perez <pedrolito@lavache.com>wrote:

> Hi,
>
> How to create an assertion that only checks that a given method is
> invoked at least once.
>
> @controller.expects(:current_user).returns(@user)
>
>
>
How about:

@controller.expects(:current_user).at_least_once.returns(@user)

Ben