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
post_with_successful_save
response.should redirect_to(admin_group_url(“1”))
end
the error:
1)
‘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.host/groups/1”
./spec/controllers/admin/groups_controller_spec.rb:246:
test log:
Processing GroupsController#update (for 0.0.0.0 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
[http://test.host/admin/groups/1]
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 127.0.0.1 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 http://127.0.0.1:3000/admin/groups/4
Completed in 0.02443 (40 reqs/sec) | DB: 0.00034 (1%) | 302 Found
[http://127.0.0.1/admin/groups]
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