Mocha: does_not_expect

Discussion in 'Ruby' started by Fernando Perez, Apr 17, 2009.

  1. Hi,

    I am writing tests for a Rails app using Test::Unit and Mocha. expects
    does a great job to make sure a method is called. But how to handle the
    fact that a method shouldn't be called?

    I have a before filter that protects the call to a given restricted
    method, and how to make sure that this method doesn't get called
    unexpectedly?
    --
    Posted via http://www.ruby-forum.com/.
     
    Fernando Perez, Apr 17, 2009
    #1
    1. Advertising

  2. Fernando Perez

    Ben Lovell Guest

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

    On Fri, Apr 17, 2009 at 1:09 PM, Fernando Perez <>wrote:

    > Hi,
    >
    > I am writing tests for a Rails app using Test::Unit and Mocha. expects
    > does a great job to make sure a method is called. But how to handle the
    > fact that a method shouldn't be called?
    >
    > I have a before filter that protects the call to a given restricted
    > method, and how to make sure that this method doesn't get called
    > unexpectedly?
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >

    some_object.expects:)expected_method).never

    Regards,
    Ben
     
    Ben Lovell, Apr 17, 2009
    #2
    1. Advertising


  3. > some_object.expects:)expected_method).never


    Damnd I never thought about such method while reading the API.

    Thank you very much.
    --
    Posted via http://www.ruby-forum.com/.
     
    Fernando Perez, Apr 17, 2009
    #3
  4. Fernando Perez

    Ben Lovell Guest

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

    On Fri, Apr 17, 2009 at 1:34 PM, Fernando Perez <>wrote:

    >
    > > some_object.expects:)expected_method).never

    >
    > Damnd I never thought about such method while reading the API.
    >
    > Thank you very much.



    Yeah I missed it first time round too :)

    Ben
     
    Ben Lovell, Apr 17, 2009
    #4
    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. Replies:
    4
    Views:
    13,518
  2. James Mead
    Replies:
    0
    Views:
    119
    James Mead
    Jul 19, 2006
  3. Joe Van Dyk

    Using Mocha to mock an object

    Joe Van Dyk, Oct 20, 2006, in forum: Ruby
    Replies:
    1
    Views:
    113
    Joe Van Dyk
    Oct 21, 2006
  4. J. B. Rainsberger

    Mocha and ActiveRecord

    J. B. Rainsberger, Nov 28, 2006, in forum: Ruby
    Replies:
    1
    Views:
    152
    J. B. Rainsberger
    Dec 2, 2006
  5. Raymond O'Connor
    Replies:
    1
    Views:
    152
    Raymond O'Connor
    Mar 8, 2007
Loading...

Share This Page