Last active
December 16, 2015 11:19
-
-
Save woods/5426861 to your computer and use it in GitHub Desktop.
This is the most succinct style I can come up with for writing routing specs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'component/component_spec_helper' | |
describe "Routing", type: :routing do | |
describe "for the home page" do | |
specify {{ get: '/' }.should route_to('lists#index') } | |
end | |
describe "for authentication" do | |
specify {{ get: '/auth/new' }.should route_to('sessions#new') } | |
specify {{ get: '/auth/37signals/callback' }.should route_to('sessions#create', provider: '37signals') } | |
specify {{ get: '/auth/failure' }.should route_to('sessions#failure') } | |
end | |
describe "for lists" do | |
specify {{ get: '/lists' }.should route_to('lists#index') } | |
specify {{ get: '/lists/new' }.should route_to('lists#new') } | |
specify {{ post: '/lists' }.should route_to('lists#create') } | |
specify {{ get: '/lists/3/edit' }.should route_to('lists#edit', id: '3') } | |
specify {{ put: '/lists/3' }.should route_to('lists#update', id: '3') } | |
specify {{ delete: '/lists/3' }.should route_to('lists#destroy', id: '3') } | |
end | |
describe "for basecamp" do | |
specify {{ post: '/basecamp/projects/1/lists' }.should route_to('basecamp#create_list', project_id: '1') } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Routing | |
for the home page | |
should route {:get=>"/"} to {:controller=>"lists", :action=>"index"} | |
for authentication | |
should route {:get=>"/auth/new"} to {:controller=>"sessions", :action=>"new"} | |
should route {:get=>"/auth/37signals/callback"} to {:provider=>"37signals", :controller=>"sessions", :action=>"create"} | |
should route {:get=>"/auth/failure"} to {:controller=>"sessions", :action=>"failure"} | |
for lists | |
should route {:get=>"/lists"} to {:controller=>"lists", :action=>"index"} | |
should route {:get=>"/lists/new"} to {:controller=>"lists", :action=>"new"} | |
should route {:post=>"/lists"} to {:controller=>"lists", :action=>"create"} | |
should route {:get=>"/lists/3/edit"} to {:id=>"3", :controller=>"lists", :action=>"edit"} | |
should route {:put=>"/lists/3"} to {:id=>"3", :controller=>"lists", :action=>"update"} | |
should route {:delete=>"/lists/3"} to {:id=>"3", :controller=>"lists", :action=>"destroy"} | |
for basecamp | |
should route {:post=>"/basecamp/projects/1/lists"} to {:project_id=>"1", :controller=>"basecamp", :action=>"create_list"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment