[rspec-users] Testing routes

Bruno Cardoso lists at ruby-forum.com
Fri Aug 20 13:43:44 EDT 2010


I have this route configurated in my routes.rb

  map.resources :accounts do |account|
    account.resources :managers, :controller => 'account_managers'

This works.

Now, I want to test the update route in my spec:

I'm doing:

route_for(:controller => 'account_managers', :action => "update",
:account_id => "2", :id => "1").should == {:path =>
"/accounts/2/managers/1", :method => :put}

I'm getting this error:

found extras <{:account_id=>"2"}>, not <{}>

Now... if I remove the "extras" he said:
route_for(:controller => 'account_managers', :action => "update", :id =>
"1").should == {:path => "/accounts/2/managers/1", :method => :put}

I get:
The recognized options <{"controller"=>"account_managers",
 "id"=>"1"}> did not match <{"controller"=>"account_managers",
"action"=>"update", "id"=>"1"}>, difference: <{"account_id"=>"2"}>

Any idea of what is going on here?
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list