123456789_123456789_123456789_123456789_123456789_

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

Relationships & Source Files
Namespace Children
Modules:
Classes:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Defined in: rspec-rails/lib/rspec/rails/matchers/routing_matchers.rb

Overview

::RSpec::Rails::Matchers to help with specs for routing code.

Class Method Summary

::RSpec::Matchers::DSL - Extended

alias_matcher

Defines a matcher alias.

define

Defines a custom matcher.

define_negated_matcher

Defines a negated matcher.

matcher
warn_about_block_args

:nocov:

Instance Method Summary

Instance Method Details

#be_routable

Passes if the route expression is recognized by the ::RSpec::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
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/matchers/routing_matchers.rb', line 101

def be_routable
  BeRoutableMatcher.new(self)
end

#route_to(*expected)

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:

[ GitHub ]

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

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