Skip to content

Instantly share code, notes, and snippets.

@bkaney
Created October 16, 2008 03:36
Show Gist options
  • Save bkaney/17072 to your computer and use it in GitHub Desktop.
Save bkaney/17072 to your computer and use it in GitHub Desktop.
Sample routing specs
describe UsersController, " (routing)" do
describe "generation" do
it "should route users's 'index' action correctly" do
route_for(:controller => 'admin/users', :action => 'index').should == "/admin/users"
end
# Other route_for's...
end
describe "recognition" do
it "should generate params for users's index action from GET admin/users" do
params_from(:get, '/admin/users').should == {:controller => 'admin/users', :action => 'index'}
params_from(:get, '/admin/users.xml').should == {:controller => 'admin/users', :action => 'index', :format => 'xml'}
params_from(:get, '/admin/users.json').should == {:controller => 'admin/users', :action => 'index', :format => 'json'}
end
# other params_from...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment