Skip to content
Browse files

Merge pull request #559 from jredville/master

add features to show how namespaced routes can be matched
  • Loading branch information...
2 parents f869484 + e795ec0 commit 7579c6e1d1c0649bc9d43a22ca8bc19b87fab2d0 @justinko justinko committed
Showing with 45 additions and 0 deletions.
  1. +13 −0 features/routing_specs/README.md
  2. +32 −0 features/routing_specs/route_to_matcher.feature
View
13 features/routing_specs/README.md
@@ -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")
View
32 features/routing_specs/route_to_matcher.feature
@@ -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

0 comments on commit 7579c6e

Please sign in to comment.
Something went wrong with that request. Please try again.