Skip to content

Commit 7579c6e

Browse files
committed
Merge pull request #559 from jredville/master
add features to show how namespaced routes can be matched
2 parents f869484 + e795ec0 commit 7579c6e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

features/routing_specs/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ customized routes, like vanity links, slugs, etc.
1515
They are also valuable for routes that should not be available:
1616

1717
{ :delete => "/accounts/37" }.should_not be_routable
18+
19+
## Specifying matched routes
20+
21+
When using the `#route_to` matcher, you can specify the expected route using a
22+
hash or a string, and it will be parsed:
23+
24+
route_to("controller#action")
25+
route_to("namespaced/controller#action")
26+
route_to(:controller => "controller",
27+
:action => "action",
28+
:params => "params")
29+
route_to(:controller => "namespaced/controller",
30+
:action => "action")

features/routing_specs/route_to_matcher.feature

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,35 @@ Feature: route_to matcher
5656

5757
When I run `rspec spec/routing/widgets_routing_spec.rb`
5858
Then the output should contain "1 failure"
59+
60+
Scenario: route spec for a namespaced route with shortcut specifier
61+
Given a file named "spec/routing/admin_routing_spec.rb" with:
62+
"""
63+
require "spec_helper"
64+
65+
describe "routes for Widgets" do
66+
it "routes /admin/accounts to the admin/accounts controller" do
67+
get("/admin/accounts").
68+
should route_to("admin/accounts#index")
69+
end
70+
end
71+
"""
72+
73+
When I run `rspec spec/routing/admin_routing_spec.rb`
74+
Then the examples should all pass
75+
76+
Scenario: route spec for a namespaced route with verbose specifier
77+
Given a file named "spec/routing/admin_routing_spec.rb" with:
78+
"""
79+
require "spec_helper"
80+
81+
describe "routes for Widgets" do
82+
it "routes /admin/accounts to the admin/accounts controller" do
83+
get("/admin/accounts").
84+
should route_to(:controller => "admin/accounts", :action => "index")
85+
end
86+
end
87+
"""
88+
89+
When I run `rspec spec/routing/admin_routing_spec.rb`
90+
Then the examples should all pass

0 commit comments

Comments
 (0)