[rspec-users] Problem with namespaced controller, form_for, and view specs

Jesse Clark jesse at jesseclark.com
Tue Nov 4 19:16:02 EST 2008


Hello,

I have encountered a problem with the view tests involving a form_for  
tag that references a namespaced controller.

My controller is:
class Admin::AuthenticationProvidersController < ApplicationController

The form_for tag from /app/views/admin/authentication_providers/ 
edit.html.erb:
<% form_for( :authentication_provider, @authentication_provider, :url  
=> { :controller=>"admin/ 
authentication_providers", :action=>"update" } ) do |f| %>

This page renders in the browser by the way and 'rake routes' shows  
that the route is valid.

However when I run:
script/spec spec/views/admin/authentication_providers/ 
edit.html.erb_spec.rb

I get:

1)
ActionView::TemplateError in '/admin/authentication_providers/ 
edit.html.erb should render edit form'
No route matches {:action=>"update", :controller=>"admin/ 
authentication_providers"}
On line #3 of admin/authentication_providers/edit.html.erb

     1: <h1>Editing authentication_provider</h1>
     2:
     3: <% form_for( :authentication_provider,  
@authentication_provider, :url => { :controller=>"admin/ 
authentication_providers", :action=>"update" } ) do |f| %>
     4:   <%= f.error_messages %>
     5:
     6:   <p>

     app/views/admin/authentication_providers/edit.html.erb:3:in  
` 
_run_erb_47app47views47admin47authentication_providers47edit46html46erb'
     spec/views/admin/authentication_providers/edit.html.erb_spec.rb:20
     script/spec:5

Seems like this might be related to:
http://rspec.lighthouseapp.com/projects/5645/tickets/488-routes-requiring-additional-parameters-fail-to-generate-in-view-specs
http://rspec.lighthouseapp.com/projects/5645/tickets/585-viewexamplegrouprender-needs-an-option-that-allows-population-of-requestpath_parameters

Any suggestions on how to work around this would be greatly appreciated.

Thanks,
-Jesse


More information about the rspec-users mailing list