[rspec-users] failing test with nested controller routes

Nola Stowe nola at rubygeek.com
Sat Oct 27 23:21:57 EDT 2007

I have googled and browsed through spec-users archives, but didn't
find anything different.

I used rspec scaffold command to generate a mvc for groups, I used
nested controller so I could have a separate interface for admin.

the specs are the same as generated, so I won't post the whole thing.
I did put the  nested routes names on the calls to the name routes:

  it "should redirect to the new group on successful save" do
    response.should redirect_to(admin_group_url("1"))

the error:
'Admin::GroupsController handling POST /admin/groups should redirect to the new
group on successful save' FAILED
expected redirect to "http://test.host/admin/groups/1", got redirect to "http://

test log:

Processing GroupsController#update (for at 2007-10-27 21:53:44) [PUT]
  Session ID:
  Parameters: {"action"=>"update", "id"=>"1", "controller"=>"admin/groups"}
Redirected to http://test.host/groups/1
Completed in 0.00061 (1647 reqs/sec) | DB: 0.00000 (0%) | 302 Found

it get redirected to http://test.host/groups/1 instead of admin/groups/1

It does work in the interface, which makes me believe that its not in
rails but something in rspec:
dev log:

Processing GroupsController#create (for at 2007-10-27 22:04:00) [POST]
  Session ID: 082b2f0103579493d5aa2a2851b4e721
  Parameters: {"commit"=>"Create", "action"=>"create",
"controller"=>"admin/groups", "group"=>{...}}
  SQL (0.000337)   INSERT INTO groups (...)
Redirected to
Completed in 0.02443 (40 reqs/sec) | DB: 0.00034 (1%) | 302 Found

it works... so the route works.. but not in the test?

here's whats in my routes.rb
  map.resources :groups, :controller => 'admin/groups',
                        :name_prefix => "admin_",
                        :path_prefix => "admin"

any ideas? the groups_url(id) is the only route that is failing in the test.

thanks :)

http://rubygeek.com - my blog featuring: Ruby, PHP and Perl
http://DevChix.com - boys can't have all the fun

More information about the rspec-users mailing list