Skip to content
This repository

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

Merged
merged 1 commit into from about 2 years ago

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 justinko closed this
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

Showing 1 unique commit by 1 author.

Jun 09, 2012
Jim Deville jredville add features to show how namespaced routes can be matched e795ec0
This page is out of date. Refresh to see the latest.
13 features/routing_specs/README.md
Source Rendered
@@ -15,3 +15,16 @@ customized routes, like vanity links, slugs, etc.
15 15 They are also valuable for routes that should not be available:
16 16
17 17 { :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")
32 features/routing_specs/route_to_matcher.feature
@@ -56,3 +56,35 @@ Feature: route_to matcher
56 56
57 57 When I run `rspec spec/routing/widgets_routing_spec.rb`
58 58 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

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.