Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add features to show how namespaced routes can be matched #559

Merged
merged 1 commit into from

3 participants

Jim Deville Don't Add Me To Your Organization a.k.a The Travis Bot Justin Ko
Jim Deville

Document how to use namespaced routes in route specs.

Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request passes (merged e795ec0 into f869484).

Justin Ko justinko merged commit 7579c6e into from
Justin Ko

Thanks for the pull!

I ended up reverting[1] the changes to the README, since the documentation[2] for #route_to is sufficient (it advises to reference assert_recognizes).

1.) 9abdc0a
2.) https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/matchers/routing_matchers.rb#L44-59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
13 features/routing_specs/README.md
View
@@ -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 features/routing_specs/route_to_matcher.feature
View
@@ -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
Something went wrong with that request. Please try again.