Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Mocha raise exception first call, return value second call

Reply
Thread Tools

Mocha raise exception first call, return value second call

 
 
Raymond O'Connor
Guest
Posts: n/a
 
      03-07-2007
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

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Raymond O'Connor
Guest
Posts: n/a
 
      03-08-2007
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!

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Raise X or Raise X()? bvdp Python 10 03-12-2012 04:08 PM
"raise (type, value, traceback)" and "raise type, value, traceback" Jack Bates Python 0 05-02-2011 05:23 PM
raise Exception or raise Exception() ernest Python 2 11-14-2010 08:14 PM
raise or not to raise [Newbie] Jacol Python 5 02-05-2007 11:46 PM
method for Exception base class to raise the exception in an expression? Bengt Richter Python 0 07-07-2005 05:07 PM



Advertisments