Here is my route from routes.rb
:
resources :books, :except => [:new, :edit] do
post "pull" => "books#update", :data => { "pull" => true }
rake routes
shows things as expected
pull_api_v1_book POST /api/v1/books/:id/pull(.:format)
api/v1/books#update {:format=>:json, :data=>{"pull"=>true}}
Running a dev server, the route works as expected:
curl -X POST http://localhost:3000/api/v1/books/3/pull?auth_token=1234567890
My spec in in books_controller_spec.rb:
post :pull, params: { :id => 12 }
But the output of the spec:
Failure/Error: post :pull, params: { :id => 12 }
ActionController::UrlGenerationError:
No route matches {:action=>"pull", :controller=>"api/v1/books", :id=>12}
Why can't rspec find the route?
Aucun commentaire:
Enregistrer un commentaire