vendredi 28 avril 2017

Rails 5 routing spec requires :path value

After upgrading Rails 4.2.8 to 5.0, all of my routing specs are failing with the same error message:

1) UsersController routing routes to SHOW
     Failure/Error: expect(get: '/users/joe-smith').to route_to('users#show', id: 'joe-smith')

       The recognized options <{"path"=>"users/joe-smith", "controller"=>"users", "action"=>"show", "id"=>"joe-smith"}> did not match <{"id"=>"joe-smith", "controller"=>"users", "action"=>"show"}>, difference:.
       --- expected
       +++ actual
       @@ -1 +1 @@
       -{"id"=>"joe-smith", "controller"=>"users", "action"=>"show"}
       +{"path"=>"users/joe-smith", "controller"=>"users", "action"=>"show", "id"=>"joe-smith"}
     # ./spec/routing/users_controller_routing_spec.rb:10:in `block (3 levels) in <top (required)>'

Finished in 0.05154 seconds (files took 6.86 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/routing/users_controller_routing_spec.rb:9 # UsersController routing routes to SHOW

The spec:

it 'routes to SHOW' do
  expect(get: '/users/joe-smith').to route_to('users#show', id: 'joe-smith')
end

Anyone have any insight into WHY this is happening? I didn't see anything in the Rails 5 CHANGELOG.

Aucun commentaire:

Enregistrer un commentaire