Hmmm...I made the changes that both you and Britt suggested and still no dice.&nbsp; I broke it down and put print statements (yeesh) in the controller around the @organization.notes &lt;&lt; @new_note statement.&nbsp; This confirms that the statement returns false&nbsp; just like the stub told it to do (so I took out the puts statement and ran the test again), but for some reason I still don&#39;t get the rendered template as set up in the else clause.&nbsp; I&#39;m not sure what&#39;s going on, but I suppose I&#39;ll just skip that test until later.<br>
<br>Thanks for the help!<br>Tiffani AB<br><br><div class="gmail_quote">On Mon, Jul 7, 2008 at 6:06 PM, Zach Dennis &lt;<a href="mailto:zach.dennis@gmail.com">zach.dennis@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div class="gmail_quote"><div class="Ih2E3d">On Mon, Jul 7, 2008 at 5:55 PM, Britt Mileshosky &lt;<a href="mailto:mileshosky@hotmail.com" target="_blank">mileshosky@hotmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
<br>
________________________________<br>
&gt; Date: Mon, 7 Jul 2008 17:27:36 -0400<br>
&gt; From: <a href="mailto:tiffani2k3@gmail.com" target="_blank">tiffani2k3@gmail.com</a><br>
&gt; To: <a href="mailto:rspec-users@rubyforge.org" target="_blank">rspec-users@rubyforge.org</a><br>
&gt; Subject: [rspec-users] Not sure why this controller spec isn&#39;t working<br>
<div>&gt;<br>
&gt; Hey folks,<br>
&gt;<br>
&gt; I&#39;ve been mocking and stubbing pretty nicely after the various bits of advice I received earlier about doing so. &nbsp;I&#39;ve come to bits of code that work in one place and not in another, though. &nbsp;I&#39;m hoping it&#39;s not something simple I&#39;ve missed. &nbsp;The code below fails even though code that is practically the same elsewhere (except different models in use) passes. &nbsp;What gives?<br>


&gt;<br>
&gt; I have:<br>
&gt;<br>
&gt; in notes_controller_spec.rb:<br>
&gt;<br>
&gt;<br>
&gt; before(:each) do<br>
&gt; &nbsp; &nbsp; @mock_note = mock_model(Note, :body =&gt; &quot;The hot dog shipment will be in later tonight.&quot;,<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :organization =&gt; @mock_org)<br>
&gt; &nbsp; &nbsp; @mock_org = mock_model(Organization, :name =&gt; &quot;Slappy&#39;s Hot Dog Palace&quot;, :notes =&gt; [@mock_note])<br>
&gt;<br>
&gt; &nbsp; &nbsp; @notes = [@mock_note]<br>
&gt; &nbsp; end<br>
&gt;<br>
&gt;<br>
&gt; it &quot;should render &#39;notes/new&#39; when the Note is setup with invalid data, i.e. without a body on POST create&quot; do<br>
&gt; &nbsp; &nbsp; &nbsp; Note.stub!(:new).and_return(@mock_note)<br>
</div>&gt; &nbsp; &nbsp; &nbsp; @notes.stub!(:&lt; &nbsp; &nbsp; &nbsp; post :create, :organization_id =&gt; @<a href="http://mock_org.id" target="_blank">mock_org.id</a>, :new_note =&gt; { :body =&gt; @mock_note.body }<br>
<div>&gt; &nbsp; &nbsp; &nbsp; response.should render_template(&quot;notes/new&quot;)<br>
&gt; &nbsp; &nbsp; end<br>
&gt;</div></blockquote></div><div><br>To add to what Britt already said, look at your example and then your before block again very carefully. Notice that you setup @notes in your before, and you use it to stub :&lt;&lt; in your example, but you never return @notes from anything. Instead you setup @mock_org to return an array with @mock_note. Although the contents of this and @notes are the same, you have created two different arrays. You are probably wanting to be dealing with the same @notes object in each of these cases.<br>

<br>Zach<br></div></div><font color="#888888"><br clear="all"><br>-- <br>Zach Dennis<br><a href="http://www.continuousthinking.com" target="_blank">http://www.continuousthinking.com</a>
</font><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>