Ahhh, clever. I see the light<br><br><div class="gmail_quote">On Wed, Apr 2, 2008 at 8:19 AM, Corey Haines <<a href="mailto:coreyhaines@gmail.com">coreyhaines@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Create an instance of the controller<div><br></div><div><br></div><div>contr = MyController.new</div><div><br></div><div>MyController.stub!(:new).and_return contr</div><div><br></div><div>contr.stub!(:method_i_want_to_stub).and_return 'sweetness'</div>
<div><br></div><div>Something like this?</div><div><br></div><font color="#888888"><div>-Corey</div></font><div><div></div><div class="Wj3C7c"><div><br><div class="gmail_quote">On Wed, Apr 2, 2008 at 12:22 AM, Jed Hurt <<a href="mailto:jed.hurt@gmail.com" target="_blank">jed.hurt@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not sure how that would work. For controller specs, I want to keep most of the controller intact so that I can verify its actual behavior. Am I missing something?<div>
<div></div><div><br><br><div class="gmail_quote">On Tue, Apr 1, 2008 at 12:12 PM, David Chelimsky <<a href="mailto:dchelimsky@gmail.com" target="_blank">dchelimsky@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On Tue, Apr 1, 2008 at 2:11 PM, Corey Haines <<a href="mailto:coreyhaines@gmail.com" target="_blank">coreyhaines@gmail.com</a>> wrote:<br>
> Could you stub out Controller.new and return your mock?<br>
<br>
</div>Bingo.<br>
<div><div></div><div><br>
><br>
><br>
><br>
> On Tue, Apr 1, 2008 at 1:19 PM, Jed Hurt <<a href="mailto:jed.hurt@gmail.com" target="_blank">jed.hurt@gmail.com</a>> wrote:<br>
> > Haha, that's about the response I was expecting; I asked with some<br>
> trepidation. I'm just looking for a quick hack to short-circuit Merb's<br>
> render method to do some view/controller isolation testing until Merb<br>
> officially supports it. I can't just stub methods on @controller (like in<br>
> Rails) because the controller is instantiated after calling dispatch.<br>
> ><br>
> ><br>
> > I suppose I could whip up a different sort of hack to accomplish the<br>
> isolation in the meantime, but now I'm not so sure; apparently I'm quite a<br>
> noob ;)<br>
> ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > On Tue, Apr 1, 2008 at 1:50 AM, Ashley Moran<br>
> <<a href="mailto:ashley.moran@patchspace.co.uk" target="_blank">ashley.moran@patchspace.co.uk</a>> wrote:<br>
> ><br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > On 01/04/2008, Jed Hurt <<a href="mailto:jed.hurt@gmail.com" target="_blank">jed.hurt@gmail.com</a>> wrote:<br>
> > ><br>
> > ><br>
> > > > Is there an easy way to stub an instance method for every new instance<br>
> of a given class? I suppose I could just redefine the method, but I'm<br>
> wondering if the RSpec mocking framework has this built in.<br>
> > ><br>
> > ><br>
> > > Hi Jed<br>
> > ><br>
> > > I hate it when other people ask this, but I can't help :) How come you<br>
> need to do this? I've always wondered what the use case for this "mocking"<br>
> strategy is<br>
> > ><br>
> > > Ashley<br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > rspec-users mailing list<br>
> > > <a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
> > > <a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
> > ><br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > rspec-users mailing list<br>
> > <a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
> > <a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
> ><br>
><br>
><br>
><br>
> --<br>
> <a href="http://www.coreyhaines.com" target="_blank">http://www.coreyhaines.com</a><br>
> The Internet's Premiere source of information about Corey Haines<br>
> _______________________________________________<br>
> rspec-users mailing list<br>
> <a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
> <a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
><br>
_______________________________________________<br>
rspec-users mailing list<br>
<a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br>
</div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>
rspec-users mailing list<br>
<a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.coreyhaines.com" target="_blank">http://www.coreyhaines.com</a><br>
The Internet's Premiere source of information about Corey Haines
</div>
</div></div><br>_______________________________________________<br>
rspec-users mailing list<br>
<a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-users" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br>