Ciao,
nel file routes.rb ho
resources :thoughts do
resources :statements, :only => [:create, :destroy]
end
se eseguo rake routes | grep statements ottengo
thought_statements POST
/thoughts/:thought_id/statements(.:format) {:action=>“create”,
:controller=>“statements”}
thought_statement DELETE
/thoughts/:thought_id/statements/:id(.:format) {:action=>“destroy”,
:controller=>“statements”}
ma non riesco a capire perch il test di queste rotte con rspec fallisce
require “spec_helper”
describe StatementsController do
describe “routing” do
it "recognizes and generates #create" do
{ :post => "/thoughts/1/statements" }.should
route_to(:controller => “statements”, :action => “create”)
end
it "recognizes and generates #destroy" do
{ :delete => "/thoughts/1/statements/1" }.should
route_to(:controller => “statements”, :action => “destroy”, :id =>
“1”)
end
end
end
con
rake spec:routing
FF…
Failures:
Failures:
- StatementsController routing recognizes and generates #create
Failure/Error: { :post => “/thoughts/1/statements” }.should
route_to(:controller => “statements”, :action => “create”)
Expected block to return true value../spec/routing/statements_routing_spec.rb:7:in `block (3
levels) in <top (required)>’
- StatementsController routing recognizes and generates #destroy
Failure/Error: { :delete => “/thoughts/1/statements/1” }.should
route_to(:controller => “statements”, :action => “destroy”, :id =>
“1”)
Expected block to return true value../spec/routing/statements_routing_spec.rb:11:in `block (3
levels) in <top (required)>’
Qualche suggerimento ?
Grazie mille.
Claudio