Your routes.rb looks funky. Are you running edge rails?
It's worthwhile if you're set on restful stuff.
I don't think the name_prefix and path_prefix stuff is really necessary.
My nested routes read more like
map.resources :groups
groups.resources :admins
end
'rake routes > /tmp/routes' is really useful when working out routing
issues.
If you're still learning restful routes, grab a copy of the beast forum
source code.
There's a model diagram somewhere on flickr also.
That was a huge help when I was getting my head around nested routes.
- Andy
Nola Stowe-5 wrote:
>
> 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 :)
>
> --
> http://rubygeek.com - my blog featuring: Ruby, PHP and Perl
> http://DevChix.com - boys can't have all the fun
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
--
View this message in context:
http://www.nabble.com/failing-test-with-nested-controller-routes-tf4705370.html#a13450365
Sent from the rspec-users mailing list archive at Nabble.com.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users