Testing routes

Hi,

I have this route configurated in my routes.rb

map.resources :accounts do |account|
account.resources :managers, :controller => ‘account_managers’
end

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”,
“action”=>“update”,
“account_id”=>“2”,
“id”=>“1”}> did not match <{“controller”=>“account_managers”,
“action”=>“update”, “id”=>“1”}>, difference: <{“account_id”=>“2”}>

Any idea of what is going on here?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs