Skip to content

Instantly share code, notes, and snippets.

@trevmex
Created July 5, 2010 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trevmex/464636 to your computer and use it in GitHub Desktop.
Save trevmex/464636 to your computer and use it in GitHub Desktop.
describe "route" do
# explicit listing
specify "days#index" do
route get('/days').should generate 'days#index' # wraps assert_generates
route 'days#index'.should recognize get('/days') # wraps assert_recognizes
end
# combined listing
specify "days#index" do
route get('/days').should be 'days#index' # This is generate and recognize (wraps assert_routing)
end
# Routing nested resources (AKA routes that recognize, but do not generate)
specify "days#index" do
route 'days#index'.should recognize get('/students/1/days') with :student_id => '1'
# or longhand (this is uglier)
route {:controller => 'days', :action => 'index', :student_id => '1'}.should recognize ('/students/1/days')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment