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

Matt Wynne matt at mattwynne.net
Sat Jul 24 04:55:16 EDT 2010


Lille,

On Sat, 24 Jul 2010 01:26 -0500, "David Chelimsky"
<dchelimsky at gmail.com> wrote:
> 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
> such.
> 
> Cheers,
> David

Most people ask for this kind of feature from their unit tests because
they're not combining mocking unit tests with end-to-end acceptance
tests. Are you using both?

> 
> 
> >
> > 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
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
> 


More information about the rspec-users mailing list