[rspec-users] Failing to stub "test" in an object , because "test" is already defined in Kernel

Constantin Gavrilescu comisarulmoldovan at gmail.com
Tue Apr 9 20:35:43 UTC 2013


I'm trying to stub the method "test" on an object, and I cannot do it with
rspec.

Example with a simpler case:

    o = Object.new
    o.stub!(:test).and_return "lol"
    o.test.should == "lol"

Error:
    Failure/Error: o.test.should == "lol"
    NoMethodError: private method `test' called for #<Object:0x13cf47e4>

This is probably because Kernel implements #test and stubs are done with
method_missing.
What's the recommended way to deal this this?



-- 
Un fleac... m-au ciuruit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20130409/f98af80c/attachment.html>


More information about the rspec-users mailing list