Mocha: expects any number of time

F

Fernando Perez

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.
 
B

Ben Lovell

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top