It's because :test was defined a private method and you're trying to access it publicly
class Object private def test ... end end There are different approaches to testing private methods. http://blog.jayfields.com/2007/11/ruby-testing-private-methods.html -or- you can test the methods that call the private method. On Tue, Apr 9, 2013 at 1:35 PM, Constantin Gavrilescu < comisarulmoldo...@gmail.com> wrote: > 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. > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- DryBlis - www.dryblis.com Samer Masry | Rails Programmer 11 Ambler Ln, Emeryville, CA 94608 Tel.:510-991-7523 | Cel.: 714-814-8508
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users