From e795ec0c0ac75a2b5c51234943e89f03fa17f9cd Mon Sep 17 00:00:00 2001 From: Jim Deville Date: Fri, 8 Jun 2012 18:09:11 -0700 Subject: [PATCH] add features to show how namespaced routes can be matched --- features/routing_specs/README.md | 13 ++++++++ .../routing_specs/route_to_matcher.feature | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/features/routing_specs/README.md b/features/routing_specs/README.md index 533f7a5476..8f0d847d25 100644 --- a/features/routing_specs/README.md +++ b/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") diff --git a/features/routing_specs/route_to_matcher.feature b/features/routing_specs/route_to_matcher.feature index 08ddb68e86..59e3400b0d 100644 --- a/features/routing_specs/route_to_matcher.feature +++ b/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 \ No newline at end of file