Yeah, I was on 1.1.4 and this solution with a few tweaks definitely worked.&nbsp; The original set up of my code called for having the Organization returned by the notes controller in a before filter, so I stubbed out this stuff in the before(:each) block.&nbsp; It ended up looking like this:<br>
<br>before(:each) do<br>&nbsp;&nbsp; @organization = stub_model(Organization, :name =&gt; &quot;Slappy&#39;s Hot Dog Palace&quot;)<br>&nbsp;&nbsp; Organization.stub!(:find).and_return(@organization)<br>end<br><br>Then, I followed Craig&#39;s lead on what the example should do with a few things taken out:<br>
<br>it &quot;should render &#39;notes/new&#39; when an empty note is submitted&quot; do<br>&nbsp; Note.stub!(:new).and_return(stub(&quot;note&quot;))<br><br>&nbsp; post :create, :appointment_id =&gt; @<a href="http://appointment.id">appointment.id</a>, :organization_id =&gt; @<a href="http://organization.id">organization.id</a>, :new_note =&gt; { :body =&gt; &quot;&quot; }<br>
&nbsp; response.should render_template(&quot;notes/new&quot;)<br>end<br><br>I kept the controller method just like it was in the original post.&nbsp; And whoooo!&nbsp; Everything passed.&nbsp; I&#39;ll be making sure I really differentiate the necessity of mock_model vs. stub_model from now on, too as a take-away from all this.&nbsp; Learning this stuff has really been interesting considering months ago the only testing I was doing was making changes in Textmate and then clicking &quot;Refresh&quot; in a browser. lol.&nbsp; <br>
<br>Thanks again!<br>Tiffani AB<br><br><div class="gmail_quote">On Mon, Jul 7, 2008 at 10:31 PM, Craig Demyanovich &lt;<a href="mailto:cdemyanovich@gmail.com">cdemyanovich@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;">
I&#39;m assuming RSpec 1.1.3+, but here&#39;s how I might write this example:<br>
<br>
describe NotesController do<br>
 &nbsp;it &quot;renders &#39;notes/new&#39; when an empty note is submitted&quot; do<br>
 &nbsp; &nbsp;Note.stub!(:new).and_return(stub(&quot;note&quot;))<br>
 &nbsp; &nbsp;organization = stub_model(Organization, :notes =&gt; stub(&quot;notes&quot;,<br>
:&lt;&lt; =&gt; false))<br>
 &nbsp; &nbsp;assigns[:organization] = organization<br>
<br>
 &nbsp; &nbsp;post :create, &quot;organization_id&quot; =&gt; organization.to_param,<br>
&quot;new_note&quot; =&gt; { &quot;body&quot; =&gt; &quot;&quot; }<br>
<div class="Ih2E3d"><br>
 &nbsp; &nbsp;response.should render_template(&quot;notes/new&quot;)<br>
 &nbsp;end<br>
</div>end<br>
<br>
I&#39;m favoring the use of stub_model and stubs instead of mock_model<br>
(and mocks) because we&#39;re not setting any expectations on the note or<br>
the organization. Rather, we&#39;re just setting them up to deliver values<br>
that are either simply required (as in Note.new returning something<br>
non-nil) or what we want (the addition of the note to the organization<br>
to fail).<br>
<br>
I&#39;ve also eliminated the idea of having existing notes on the<br>
organization. It&#39;s not central to what&#39;s being spec&#39;d, so it&#39;s out.<br>
<br>
Furthermore, I made the submitted note&#39;s body empty because that&#39;s<br>
what was in the original description of the it block. That those two<br>
didn&#39;t match bothered me.<br>
<br>
Finally, I simplified the description of the it block to what I<br>
thought the essence of your example was; I hope that I&#39;m at least<br>
close. :-)<br>
<br>
Please let the list know if this helped or if you already revisited<br>
the problem and solved it. I think we&#39;re interested in what ends up<br>
working for you.<br>
<br>
Regards,<br>
<font color="#888888">Craig<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<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>
</div></div></blockquote></div><br>