module RSpec::Rails::Matchers::RoutingMatchers

Public Instance Methods

be_routable() click to toggle source

Passes if the route expression is recognized by the Rails router based on the declarations in `config/routes.rb`. Delegates to `RouteSet#recognize_path`.

@example

You can use route helpers provided by rspec-rails.

{:get =>  "/a/path"}.should be_routable
{:post => "/another/path"}.should be_routable
{:put => "/yet/another/path"}.should_not be_routable
# File lib/rspec/rails/matchers/routing_matchers.rb, line 95
def be_routable
  BeRoutableMatcher.new(self)
end
route_to(*expected) click to toggle source

Delegates to `assert_recognizes`. Supports short-hand controller/action declarations (e.g. `“controller#action”`).

@example

{ :get => "/things/special" }.should route_to(
  :controller => "things",
  :action     => "special"
)

{ :get => "/things/special" }.should route_to("things#special")

@see api.rubyonrails.org/classes/ActionDispatch/Assertions/RoutingAssertions.html#method-i-assert_recognizes

# File lib/rspec/rails/matchers/routing_matchers.rb, line 56
def route_to(*expected)
  RouteToMatcher.new(self, *expected)
end