Mock a %x call

Discussion in 'Ruby' started by Fernando Perez, May 19, 2009.

  1. Hi,

    Is it possible to mock such method call?

    I tried: Kernel.expects:)'%x').returns('whatever').

    But I get the following error:
    SyntaxError: compile error
    /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/class_method.rb:40:
    syntax error, unexpected '(', expecting '\n' or ';'
    def %x(*args, &block); mocha.method_missing:)%x, *args, &block); end
    --
    Posted via http://www.ruby-forum.com/.
    Fernando Perez, May 19, 2009
    #1
    1. Advertising

  2. Fernando Perez

    Tim Pease Guest

    On Tue, May 19, 2009 at 8:07 AM, Fernando Perez <> wrote:
    > Hi,
    >
    > Is it possible to mock such method call?
    >
    > I tried: Kernel.expects:)'%x').returns('whatever').
    >
    > But I get the following error:
    > SyntaxError: compile error
    > /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/class_method.rb:40:
    > syntax error, unexpected '(', expecting '\n' or ';'
    > def %x(*args, &block); mocha.method_missing:)%x, *args, &block); end


    The various % constructs in ruby are handled by the parser and,
    therefore, cannot be mocked using method stubbing employed by mocha,
    rspec mocks, et al.

    Blessings,
    TwP
    Tim Pease, May 19, 2009
    #2
    1. Advertising

  3. Hi,

    At Tue, 19 May 2009 23:07:58 +0900,
    Fernando Perez wrote in [ruby-talk:336901]:
    > I tried: Kernel.expects:)'%x').returns('whatever').
    >
    > But I get the following error:
    > SyntaxError: compile error
    > /usr/local/ruby1.8.7/lib/ruby/gems/1.8/gems/mocha-0.9.5/lib/mocha/class_method.rb:40:
    > syntax error, unexpected '(', expecting '\n' or ';'
    > def %x(*args, &block); mocha.method_missing:)%x, *args, &block); end


    Maybe, expects:)`)?

    --
    Nobu Nakada
    Nobuyoshi Nakada, May 19, 2009
    #3
    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. =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=

    Mock objects for nunit tests?

    =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=, Mar 17, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    4,974
  2. Ken Connor

    Mock Objects for Web Applications

    Ken Connor, Sep 15, 2003, in forum: Java
    Replies:
    0
    Views:
    313
    Ken Connor
    Sep 15, 2003
  3. Ken
    Replies:
    0
    Views:
    358
  4. fc2

    Where's Java mock exam?

    fc2, Nov 1, 2005, in forum: Java
    Replies:
    0
    Views:
    343
  5. Czterysta Czwarty
    Replies:
    0
    Views:
    501
    Czterysta Czwarty
    Jun 14, 2010
Loading...

Share This Page