Skip to content

Instantly share code, notes, and snippets.

@bushymark
Created November 2, 2010 02:11
Show Gist options
  • Save bushymark/659174 to your computer and use it in GitHub Desktop.
Save bushymark/659174 to your computer and use it in GitHub Desktop.
Output from Controller specs
Failures:
1) VotesController routing recognizes and generates #delete
Failure/Error: { :delete => "/discussions/posts/1/votes/1" }.should route_to(:controller => "discussions/votes", :action => "destroy", :id => "1", :post_id => "1")
No route matches "/discussions/posts/1/votes/1"
# ./spec/routing/votes_routing_spec.rb:6:in `block (3 levels) in <top (required)>'
2) VotesController routing recognizes and generates #create
Failure/Error: { :post => "/discussions/posts/1/votes" }.should route_to(:controller => "discussions/votes", :action => "create", :post_id => '1')
No route matches "/discussions/posts/1/votes"
# ./spec/routing/votes_routing_spec.rb:9:in `block (3 levels) in <top (required)>'
Finished in 0.11075 seconds
7 examples, 2 failures
 → rake routes
discussions_post_flags POST /discussions/posts/:post_id/flags(.:format) {:action=>"create", :controller=>"discussions/flags"}
discussions_post_flag DELETE /discussions/posts/:post_id/flags/:id(.:format) {:action=>"destroy", :controller=>"discussions/flags"}
discussions_post_votes POST /discussions/posts/:post_id/votes(.:format) {:action=>"create", :controller=>"discussions/votes"}
discussions_post_vote DELETE /discussions/posts/:post_id/votes/:id(.:format) {:action=>"destroy", :controller=>"discussions/votes"}
discussions_post_favorites POST /discussions/posts/:post_id/favorites(.:format) {:action=>"create", :controller=>"discussions/favorites"}
discussions_post_favorite DELETE /discussions/posts/:post_id/favorites/:id(.:format) {:action=>"destroy", :controller=>"discussions/favorites"}
namespace :discussions do
resources :posts, :only => [:show, :create, :update, :destroy] do
resources :replies, :only => :create
resources :flags, :only => [:create, :destroy]
resources :votes, :only => [:create, :destroy]
resources :favorites, :only => [:create, :destroy]
end
end
# same result on flags, votes, favorites, or replies
describe "routing" do
it "recognizes and generates #delete" do
{ :delete => "/discussions/posts/1/votes/1" }.should route_to(:controller => "discussions/votes", :action => "destroy", :id => "1", :post_id => "1")
end
it "recognizes and generates #create" do
{ :post => "/discussions/posts/1/votes" }.should route_to(:controller => "discussions/votes", :action => "create", :post_id => '1')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment