Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions features/routing_specs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,16 @@ customized routes, like vanity links, slugs, etc.
They are also valuable for routes that should not be available:

{ :delete => "/accounts/37" }.should_not be_routable

## Specifying matched routes

When using the `#route_to` matcher, you can specify the expected route using a
hash or a string, and it will be parsed:

route_to("controller#action")
route_to("namespaced/controller#action")
route_to(:controller => "controller",
:action => "action",
:params => "params")
route_to(:controller => "namespaced/controller",
:action => "action")
32 changes: 32 additions & 0 deletions features/routing_specs/route_to_matcher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,35 @@ Feature: route_to matcher

When I run `rspec spec/routing/widgets_routing_spec.rb`
Then the output should contain "1 failure"

Scenario: route spec for a namespaced route with shortcut specifier
Given a file named "spec/routing/admin_routing_spec.rb" with:
"""
require "spec_helper"

describe "routes for Widgets" do
it "routes /admin/accounts to the admin/accounts controller" do
get("/admin/accounts").
should route_to("admin/accounts#index")
end
end
"""

When I run `rspec spec/routing/admin_routing_spec.rb`
Then the examples should all pass

Scenario: route spec for a namespaced route with verbose specifier
Given a file named "spec/routing/admin_routing_spec.rb" with:
"""
require "spec_helper"

describe "routes for Widgets" do
it "routes /admin/accounts to the admin/accounts controller" do
get("/admin/accounts").
should route_to(:controller => "admin/accounts", :action => "index")
end
end
"""

When I run `rspec spec/routing/admin_routing_spec.rb`
Then the examples should all pass