I&#39;m trying to write my first view spec; I&#39;ve done some controller specs with integrated views, but thought that isolating the views for some of these tests might be nice.<br><br>So I wrote this:<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
describe PlayerContainer, &quot;show&quot; do<br><br>&nbsp; PARENT_ID = 12<br>&nbsp; CHILD_NAME = &#39;Child Name&#39;<br>&nbsp; PARENT_NAME = &#39;Parent Name&#39;<br>&nbsp; <br>&nbsp; before(:each) do<br>&nbsp;&nbsp;&nbsp; parent = mock_model(Customer)<br>&nbsp;&nbsp;&nbsp; 
parent.should_receive(:name).and_return(PARENT_NAME)<br>&nbsp;&nbsp;&nbsp; parent.should_receive(:id).and_return(PARENT_ID)<br>&nbsp;&nbsp;&nbsp; @container = mock_model(PlayerContainer)<br>&nbsp;&nbsp;&nbsp; @container.should_receive(:name).and_return(CHILD_NAME)<br>
&nbsp;&nbsp;&nbsp; @container.should_receive(:parent).and_return(parent)<br>&nbsp;&nbsp;&nbsp; @container.should_receive(:parent_id).and_return(PARENT_ID)<br>&nbsp;&nbsp;&nbsp; assigns[:container] = @container<br>&nbsp;&nbsp;&nbsp; params[:locale] = &#39;en-US&#39;<br>&nbsp; end<br><br>
&nbsp; it &quot;should display name&quot; do<br>&nbsp;&nbsp;&nbsp; @container.should_receive(:note).and_return(nil)<br>&nbsp;&nbsp;&nbsp; render &quot;/player_containers/show&quot;<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; response.should have_tag(&#39;span#name&#39;, CHILD_NAME)<br>
&nbsp; end<br>&nbsp; <br>&nbsp; it &quot;should display note, when present&quot;<br>&nbsp; <br>&nbsp; it &quot;should display empty note, when not present&quot;<br><br>end</blockquote><div><br>If I fire up script/server and point the browser at:<br>
<a href="http://localhost:3000/0.1/en-US/player_containers/6">http://localhost:3000/0.1/en-US/player_containers/6</a><br><br>It works just fine.&nbsp; However, when I run the spec, I get:<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
1)<br>ActionView::TemplateError in &#39;PlayerContainer show should display name&#39;<br>customer_url failed to generate from {:action=&gt;&quot;show&quot;, :id=&gt;&quot;12&quot;, :controller=&gt;&quot;customers&quot;}, expected: {:action=&gt;&quot;show&quot;, :controller=&gt;&quot;customers&quot;}, diff: {:id=&gt;&quot;12&quot;}
<br>On line #11 of app/views/player_containers/show.rhtml<br><br>&nbsp;&nbsp;&nbsp; 8:&nbsp;&nbsp; &lt;div class=&quot;propsheet-row&quot;&gt;<br>&nbsp;&nbsp;&nbsp; 9:&nbsp;&nbsp;&nbsp;&nbsp; &lt;b&gt;&lt;label for=&quot;name&quot;&gt;Parent:&lt;/label&gt;&lt;/b&gt;<br>&nbsp;&nbsp;&nbsp; 10:&nbsp;&nbsp;&nbsp;&nbsp; &lt;span class=&quot;propsheet-value&quot; id=&quot;parent&quot;&gt;
<br>&nbsp;&nbsp;&nbsp; 11:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%= link_to @<a href="http://container.parent.name">container.parent.name</a>, parent_org_path(@container, :action =&gt; &#39;show&#39;) %&gt;<br>&nbsp;&nbsp;&nbsp; 12:&nbsp;&nbsp;&nbsp;&nbsp; &lt;/span&gt;<br>&nbsp;&nbsp;&nbsp; 13:&nbsp;&nbsp; &lt;/div&gt;<br>
&nbsp;&nbsp;&nbsp; 14: <br><br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1273:in `raise_named_route_error&#39;<br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1245:in `generate&#39;
<br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/url_rewriter.rb:104:in `rewrite_path&#39;<br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/url_rewriter.rb:69:in `rewrite&#39;
<br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/base.rb:522:in `url_for&#39;<br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/url_helper.rb:27:in `send&#39;<br>&nbsp;&nbsp;&nbsp; /usr/lib/ruby/gems/1.8/gems/actionpack-
1.13.3/lib/action_view/helpers/url_helper.rb:27:in `url_for&#39;<br>&nbsp;&nbsp;&nbsp; (eval):19:in `unsafe_customer_path&#39;<br>&nbsp;&nbsp;&nbsp; #{RAILS_ROOT}/lib/url_helper_advice.rb:21:in `customer_path&#39;<br>&nbsp;&nbsp;&nbsp; #{RAILS_ROOT}/app/helpers/application_helper.rb:19:in `parent_org_path&#39;
<br>&nbsp;&nbsp;&nbsp; #{RAILS_ROOT}/app/views//player_containers/show.rhtml:11:in `_run_rhtml_47app47views47player_containers47show46rhtml&#39;<br></blockquote><br>&nbsp;My assumption is that I&#39;ve done something wrong in RSpec, but I&#39;m not really sure what; the view seems to work, so as far as I can tell the view and the route are fine, but the test is not.&nbsp; The error seems to imply the route shouldn&#39;t have an ID, but ... well ... it should, and it does when I fire up the page in my browser, so I&#39;m not entirely sure why running an RSpec view spec should get me a different result on a named route generation.
<br><br>Suggestions?<br></div><br>&nbsp; - Geoffrey<br>-- <br>Geoffrey Wiseman<br>