Hier meine Route von routes.rb
ist:Fehler in rspec "Keine Route übereinstimmt", aber Route zeigt in Rake Routen bis
resources :books, :except => [:new, :edit] do
post "pull" => "books#update", :data => { "pull" => true }
rake routes
zeigt Dinge wie
pull_api_v1_book POST /api/v1/books/:id/pull(.:format)
api/v1/books#update {:format=>:json, :data=>{"pull"=>true}}
einen Entwickler-Server ausgeführt wird, Die Route funktioniert wie erwartet:
curl -X POST http://localhost:3000/api/v1/books/3/pull?auth_token=1234567890
Meine Daten in books_controller_spec.rb:
describe "pull api" do
it "should not fail" do
post :pull, params: { :id => 12 }
end
end
Aber der Ausgang des spec:
Failure/Error: post :pull, params: { :id => 12 }
ActionController::UrlGenerationError:
No route matches {:action=>"pull", :controller=>"api/v1/books", :id=>12}
Warum die Route finden nicht RSpec können?
Können Sie in die Spezifikation einfügen, als Referenz, die hilfreich sein wird. –
Es ist dort (sehr einfach eine Linie spec). Ich habe es jetzt ein bisschen deutlicher gemacht. 'post: pull, params: {: id => 12}' – wildabeast