[rspec-users] newbie: how to preserve NoMethodError under stubbing?

Wincent Colaiuta win at wincent.com
Sat Jul 24 09:52:40 EDT 2010


El 24/07/2010, a las 15:34, Lille escribió:

> David,
> 
> Yes, your reading of the request is what I originally meant.
> 
> I appreciate the points made by others in this thread and the thread
> David has referred to.
> 
> As I continue to learn RSpec I will undoubtedly avail myself of the
> approaches recommended above or in the linked thread, but I think an
> argument to stub() per the following could be useful:
> 
> f.stub(:barr, :throw_no_such_method_error=>true)
> #=> Error: "The Foo class does not have a 'barr' method. Perhaps you
> meant to stub 'bar'"

How about this:

  f.stub.existing(:bar)

That's probably RR influencing me there, which employs things like "stub.proxy" and so on. So maybe not such a good idea for rspec-mocks.

Cheers,
Wincent





More information about the rspec-users mailing list