Module: RSpec::Rails::Matchers::RoutingMatchers Private

Extended by:
Matchers::DSL
Included in:
ControllerExampleGroup, RoutingExampleGroup
Defined in:
lib/rspec/rails/matchers/routing_matchers.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Matchers to help with specs for routing code.

Defined Under Namespace

Modules: RouteHelpers

Instance Method Summary (collapse)

Instance Method Details

- (Object) be_routable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Examples:

You can use route helpers provided by rspec-rails.

expect(:get  => "/a/path").to be_routable
expect(:post => "/another/path").to be_routable
expect(:put  => "/yet/another/path").to be_routable


97
98
99
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 97

def be_routable
  BeRoutableMatcher.new(self)
end

- (Object) route_to(*expected)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Examples:


expect(:get => "/things/special").to route_to(
  :controller => "things",
  :action     => "special"
)

expect(:get => "/things/special").to route_to("things#special")

See Also:



61
62
63
# File 'lib/rspec/rails/matchers/routing_matchers.rb', line 61

def route_to(*expected)
  RouteToMatcher.new(self, *expected)
end