Skip to content

Instantly share code, notes, and snippets.

@wincent
Created July 7, 2010 12:29
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 wincent/466624 to your computer and use it in GitHub Desktop.
Save wincent/466624 to your computer and use it in GitHub Desktop.
describe IssuesController do
describe 'routing' do
specify { get('/issues').should have_routing('issues#index') }
specify { get('/issues/new').should have_routing('issues#new') }
specify { get('/issues/123').should have_routing('issues#show', :id => '123') }
specify { get('/issues/123/edit').should have_routing('issues#edit', :id => '123') }
specify { put('/issues/123').should have_routing('issues#update', :id => '123') }
specify { delete('/issues/123').should have_routing('issues#destroy', :id => '123') }
specify { post('/issues').should have_routing('issues#create') }
describe 'index pagination' do
specify { get('/issues/page/2').should have_routing('issues#index', :page => '2') }
it 'rejects non-numeric :page params' do
get('/issues/page/foo').should_not be_recognized
end
end
describe 'non-RESTful routes' do
specify { get('/issues/search').should have_routing('issues#search') }
specify { post('/issues/search').should have_routing('issues#search') }
end
end
end
describe IssuesController do
describe 'router' do
it { should have_routing('/issues').for('issues#index') }
it { should have_routing('/issues/new').for('issues#new') }
it { should have_routing('/issues/123').for('issues#show', :id => '123') }
it { should have_routing('/issues/123/edit').for('issues#edit', :id => '123') }
it { should have_routing(put '/issues/123').for('issues#update', :id => '123') }
it { should have_routing(delete '/issues/123').for('issues#destroy', :id => '123') }
it { should have_routing(post '/issues').for('issues#create') }
describe 'index pagination' do
it { should have_routing('/issues/page/2').for('issues#index', :page => '2') }
it 'rejects non-numeric :page params' do
router.should_not recognize('/issues/page/foo')
end
end
describe 'non-RESTful routes' do
it { should have_routing('/issues/search').for('issues#search') }
it { should have_routing(post '/issues/search').for('issues#search') }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment