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

David Chelimsky dchelimsky at gmail.com
Sat Jul 24 02:26:27 EDT 2010

On Fri, Jul 23, 2010 at 6:46 PM, Lille <lille.penguini at gmail.com> wrote:
> Hi,
> I've been browsing the RSpec book and the RDoc, but I can't see how to
> ensure the following:
> Stub an instance with a method it doesn't have and raise NoMethodError
> (or something like it.)

RSpec doesn't support anything like that. I'm not sure if any of the
Ruby frameworks do, though I've been involved with conversations about
this sort of thing before.

I wouldn't want behaviour like this myself unless it could be invoked
explicitly with a command line argument, but was otherwise off. In
other words, you could do something like:

  rspec spec --audit-stubbed-methods

And then that would generate some sort of report.

Feel free to submit a feature request to
http://github.com/rspec/rspec-mocks if you're interested in pursuing


> I want to do this because I don't want to use incorrect names for my
> dependency methods...
> Thanks,
> Lille
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list