Mocha raise exception first call, return value second call

Discussion in 'Ruby' started by Raymond O'Connor, Mar 7, 2007.

  1. 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/.
     
    Raymond O'Connor, Mar 7, 2007
    #1
    1. Advertising

  2. Re: Mocha raise exception first call, return value second ca

    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/.
     
    Raymond O'Connor, Mar 8, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bengt Richter
    Replies:
    0
    Views:
    370
    Bengt Richter
    Jul 7, 2005
  2. Jacol

    raise or not to raise [Newbie]

    Jacol, Feb 3, 2007, in forum: Python
    Replies:
    5
    Views:
    416
    Gabriel Genellina
    Feb 5, 2007
  3. ernest
    Replies:
    2
    Views:
    297
    Roy Smith
    Nov 14, 2010
  4. Jack Bates
    Replies:
    0
    Views:
    284
    Jack Bates
    May 2, 2011
  5. bvdp

    Raise X or Raise X()?

    bvdp, Mar 11, 2012, in forum: Python
    Replies:
    10
    Views:
    383
    Stefan Behnel
    Mar 12, 2012
Loading...

Share This Page