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,955
Messages
2,570,117
Members
46,705
Latest member
v_darius

Latest Threads

Top