[rspec-users] Stub an instance method for every new instance of a class

David Chelimsky dchelimsky at gmail.com
Tue Apr 1 14:12:24 EDT 2008


On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines <coreyhaines at gmail.com> wrote:
> Could you stub out Controller.new and return your mock?

Bingo.

>
>
>
> On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt <jed.hurt at gmail.com> wrote:
> > Haha, that's about the response I was expecting; I asked with some
> trepidation. I'm just looking for a quick hack to short-circuit Merb's
> render method to do some view/controller isolation testing until Merb
> officially supports it. I can't just stub methods on @controller (like in
> Rails) because the controller is instantiated after calling dispatch.
> >
> >
> > I suppose I could whip up a different sort of hack to accomplish the
> isolation in the meantime, but now I'm not so sure; apparently I'm quite a
> noob ;)
> >
> >
> >
> >
> >
> > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran
> <ashley.moran at patchspace.co.uk> wrote:
> >
> > >
> > >
> > >
> > >
> > > On 01/04/2008, Jed Hurt <jed.hurt at gmail.com> wrote:
> > >
> > >
> > > > Is there an easy way to stub an instance method for every new instance
> of a given class? I suppose I could just redefine the method, but I'm
> wondering if the RSpec mocking framework has this built in.
> > >
> > >
> > > Hi Jed
> > >
> > > I hate it when other people ask this, but I can't help :)  How come you
> need to do this?  I've always wondered what the use case for this "mocking"
> strategy is
> > >
> > > Ashley
> > >
> > >
> > > _______________________________________________
> > > 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
> >
>
>
>
> --
> http://www.coreyhaines.com
>  The Internet's Premiere source of information about Corey Haines
> _______________________________________________
>  rspec-users mailing list
>  rspec-users at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list