Ahhh, clever. I see the light<br><br><div class="gmail_quote">On Wed, Apr 2, 2008 at 8:19 AM, Corey Haines &lt;<a href="mailto:coreyhaines@gmail.com">coreyhaines@gmail.com</a>&gt; 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 &#39;sweetness&#39;</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 &lt;<a href="mailto:jed.hurt@gmail.com" target="_blank">jed.hurt@gmail.com</a>&gt; wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I&#39;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 &lt;<a href="mailto:dchelimsky@gmail.com" target="_blank">dchelimsky@gmail.com</a>&gt; 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 &lt;<a href="mailto:coreyhaines@gmail.com" target="_blank">coreyhaines@gmail.com</a>&gt; wrote:<br>



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