Thanks very much.&nbsp; I feel like a bit of a fool, now, for the odd error.<br><br>Changing from:<br>&nbsp;&nbsp;&nbsp; &nbsp; &lt;%= link_to(<a href="http://a.name">a.name</a>,actor_path(@customer,@project),{:class=&gt;&quot;show&quot;,:title=&gt;&quot;Show actor details&quot;}) -%&gt;
<br>To<br>&nbsp;&nbsp;&nbsp; &nbsp; &lt;%= link_to(<a href="http://a.name">a.name</a>,actor_path(@customer,@project,a),{:class=&gt;&quot;show&quot;,:title=&gt;&quot;Show actor details&quot;}) -%&gt;<br><br>Caused everything to work like a champ.&nbsp; And uncovered an interesting bug.&nbsp; When not specifying the actor &#39;a&#39;, the link is generated (in the page), but with id=1.&nbsp; No idea if/when I would have caught that.
<br><br>Thanks again David, and all the RSpec&#39;ers out there.<br><br>Also, thanks for the multi-nesting pointer.<br><br>Scott<br><br><br><div><span class="gmail_quote">On 9/10/07, <b class="gmail_sendername">David Chelimsky
</b> &lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On 9/10/07, Scott Sehlhorst &lt;
<a href="mailto:scott@tynerblain.com">scott@tynerblain.com</a>&gt; wrote:<br>&gt; Thanks, first, to everyone who&#39;s asked and answered questions on this list,<br>&gt; and to the creators of RSpec - it is all very helpful.&nbsp;&nbsp;I&#39;ve searched the
<br>&gt; mailing list, and had a couple 2hr googling sessions that didn&#39;t help me<br>&gt; find an answer.<br>&gt;<br>&gt; I&#39;ve run into a problem getting my first non-trivial view spec to run.&nbsp;&nbsp;I<br>&gt; get an error when trying to generate a link_to() to another resource.&nbsp;&nbsp;Here
<br>&gt; is an overview of the situation, then the code:<br>&gt;<br>&gt;<br>&gt; I&#39;m using a restful design<br>&gt; I&#39;m using nested (multiply nested) resources<br>&gt; I am trying to test a show.rhtml view, that includes links (link_to) to
<br>&gt; resources managed by another controller<br>&gt; The use_case model has a many-to-may through relationship with actors, and<br>&gt; I&#39;m displaying links to the associated actors on the use_case page<br>&gt; I can&#39;t get the links to generate when running rspec (but it works great in
<br>&gt; the app)<br>&gt; I am in the early stages of the project, and want to move forward BDD, but I<br>&gt; have some existing code that I need to test before I can start moving<br>&gt; forward again.<br>&gt; My theories:&nbsp;&nbsp;I need to stub the controller (for the other resource), or I
<br>&gt; need to stub something else.<br>&gt;<br>&gt; Here&#39;s the command I&#39;m running to drive RSpec<br>&gt;<br>&gt;&nbsp;&nbsp;ruby script/spec -f s spec/views<br>&gt;<br>&gt; Here&#39;s the error that I get<br>&gt;<br>&gt;&nbsp;&nbsp;1)
<br>&gt; ActionView::TemplateError in &#39;UseCase showing a use case should display the<br>&gt; use case identifier&#39;<br>&gt;&nbsp;&nbsp;actor_url failed to generate from {:customer_id=&gt;&quot;1&quot;,<br>&gt; :controller=&gt;&quot;actors&quot;, :action=&gt;&quot;show&quot;, :project_id=&gt;&quot;1&quot;}, expecte
<br>&gt; d: {:controller=&gt;&quot;actors&quot;, :action=&gt;&quot;show&quot;}, diff: {:customer_id=&gt;&quot;1&quot;,<br>&gt; :project_id=&gt;&quot;1&quot;}<br>&gt; On line #22 of app/views/use_cases/show.rhtml<br>&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp; 19:&nbsp;&nbsp; &lt;ul&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;% @primary_actors.each do |a| %&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 21:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;li&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;22:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%=<br>&gt; link_to(<a href="http://a.name">a.name</a>,actor_path(@customer,@project),{:class=&gt;&quot;show&quot;,:title=&gt;&quot;Show
<br>&gt; actor details&quot;}) -%&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 23:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;%= link_to(&quot;Remove<br>&gt; assignment&quot;,participation_path(@customer,@project,@use_case.participations.find_by<br>&gt; _actor_id(a)),{:class=&gt;&quot;delete&quot;,:title=&gt;&quot;Remove the
<br>&gt; assignment of this actor to this use case&quot;, :confirm =&gt; &#39;Are you sur<br>&gt; e you want to remove this assignment?&#39;, :method =&gt; :delete})-%&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;24:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/li&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 25:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;% end %&gt;
<br>&gt;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in<br>&gt; `raise_named_route_error&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in
<br>&gt; `generate&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in<br>&gt; `rewrite_path&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in
<br>&gt; `rewrite&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in<br>&gt; `url_for&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in
<br>&gt; `url_for&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(eval):19:in `actor_path&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; #{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in<br>&gt; `_run_rhtml_47app47views47use_cases47show46rhtml&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; #{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in
<br>&gt; `_run_rhtml_47app47views47use_cases47show46rhtml&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:326:in<br>&gt; `compile_and_render_template&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:301:in
<br>&gt; `render_template&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/base.rb:260:in<br>&gt; `render_file&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:806:in
<br>&gt; `render_file&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:741:in<br>&gt; `render_with_no_layout&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/layout.rb:256:in
<br>&gt; `render_without_benchmark&#39;<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in<br>&gt; `render&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; c:/dev/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure&#39;
<br>&gt;<br>&gt; #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:50:in<br>&gt; `render&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/view.rb:55:in
<br>&gt; `render&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; spec/views/use_cases/show_view_spec.rb:40<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:17:in<br>&gt; `proc&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/composite_proc_builder.rb:12:in
<br>&gt; `proc&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:71:in<br>&gt; `before_example&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:25:in<br>
&gt; `run&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; c:/dev/ruby/lib/ruby/1.8/timeout.rb:48:in `timeout&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/example.rb:24:in<br>&gt; `run&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:81:in
<br>&gt; `run&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/dsl/behaviour.rb:75:in<br>&gt; `run&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:58:in<br>
&gt; `run_behaviours&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:57:in<br>&gt; `run_behaviours&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb:21:in
<br>&gt; `run&#39;<br>&gt;<br>&gt; C:/dev/svn/sherpa/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17:in<br>&gt; `run&#39;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;script/spec:4<br>&gt;<br>&gt; Here&#39;s part of my routes.rb, showing the nested resources
<br>&gt;<br>&gt;&nbsp;&nbsp; map.resources :customers do |customers|<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; customers.resources :projects do |projects|<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;projects.resources :actors<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; projects.resources :use_cases<br>&gt;<br>&gt;<br>&gt; Here&#39;s some of the stubbing that I am using to set up the spec
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@customer = mock_model(Customer,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :id =&gt; 1,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:to_param =&gt; &quot;1&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; @project = mock_model(Project,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:id =&gt; 1,
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :customer_id =&gt; 1,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:to_param =&gt; &quot;1&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>&gt;<br>&gt; I&#39;ve also stubbed objects to create the following :assigns<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; assigns[:customer] = @customer
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assigns[:project] = @project<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; assigns[:use_case] = @use_case<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assigns[:primary_actors] = @primary_actors<br>&gt;<br>&gt; I suspect that there is something else that needs to be stubbed - actors
<br>&gt; controller, maybe?&nbsp;&nbsp;I really don&#39;t know.&nbsp;&nbsp;If anyone can point me in the<br>&gt; right direction, or tell me where in the error message to dig deeper, that<br>&gt; would be awesome.<br>&gt;<br>&gt; If I left out any important information, please let me know!&nbsp;&nbsp;And a huge
<br>&gt; thanks in advance to anyone who can help me out, or explain why this isn&#39;t<br>&gt; supported, or point me towards any docs or articles that address this issue<br>&gt; (because I will have it a zillion times, as almost all views in my app
<br>&gt; display content and links from more than one model).<br><br>I don&#39;t think it&#39;s related to rspec. Note that the top of the error stack says:<br><br>&nbsp;&nbsp;#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in
<br>`raise_named_route_error&#39;<br><br>So the error is likely related to this bit:<br><br>&nbsp;&nbsp;actor_path(@customer,@project)<br><br>Given the nesting that you&#39;re doing multi-level nesting (which is not<br>recommended btw - read
<br><a href="http://weblog.jamisbuck.org/2007/2/5/nesting-resources">http://weblog.jamisbuck.org/2007/2/5/nesting-resources</a>), I believe<br>that the path should be either:<br><br>customer_project_actor_path(@customer, @project, @actor)
<br><br>or<br><br>customer_project_actors_path(@customer, @project)<br><br>HTH,<br>David<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">http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br><br clear="all"><br>-- <br>Scott Sehlhorst, President Tyner Blain LLC<br>
<a href="http://tynerblain.com/blog">http://tynerblain.com/blog</a><br><a href="http://tynerblain.com/nexus">http://tynerblain.com/nexus</a>