Mocha raise exception first call, return value second call

  • Thread starter Raymond O'Connor
  • Start date
R

Raymond O'Connor

Is there a way to have mocha raise an exception the first time an stub
is called, and then return a value the second time it is called?

First example, I'm trying to connect to a server and test the case where
my first attempt raises a 'Server busy' exception or something of that
sort. So I wait, then retry and then the second time the connection is
successful.

Cheers!
Ray
 
R

Raymond O'Connor

Thanks for the help both of you! I ended up using the method James
proposed (it was cleaner ;) ).

Very interesting thread too. From a usability standpoint, adding a
raises method to TestCase seems to provide the most intuitive syntax...
at least for me it does. Can't wait to see how things pan out!
 

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,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top