|
shared_examples_for "default crud routing" do |
|
|
|
let(:random_id_for_routing) {rand(2000)} |
|
let(:controller_name) {described_class.to_s.underscore.gsub(/_controller/, '')} |
|
|
|
it "should route to index action" do |
|
{:get => "/#{controller_name}"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'index' |
|
) |
|
end |
|
|
|
it "should route to show action" do |
|
{:get => "/#{controller_name}/#{random_id_for_routing}"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'show', |
|
:id => "#{random_id_for_routing}" |
|
) |
|
end |
|
|
|
it "should route to destroy action" do |
|
{:delete => "/#{controller_name}/#{random_id_for_routing}"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'destroy', |
|
:id => "#{random_id_for_routing}" |
|
) |
|
end |
|
|
|
it "should route to new action" do |
|
{:get => "/#{controller_name}/new"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'new' |
|
) |
|
end |
|
|
|
it "should route to edit action" do |
|
{:get => "/#{controller_name}/#{random_id_for_routing}/edit"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'edit', |
|
:id => "#{random_id_for_routing}" |
|
) |
|
end |
|
|
|
it "should route to create action" do |
|
{:post => "/#{controller_name}"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'create' |
|
) |
|
end |
|
|
|
it "should route to update action" do |
|
{:put => "/#{controller_name}/#{random_id_for_routing}"}.should route_to( |
|
:controller => controller_name, |
|
:action => 'update', |
|
:id => "#{random_id_for_routing}" |
|
) |
|
end |
|
|
|
end |