class RSpec::Rails::Matchers::RoutingMatchers::RouteToMatcher
@private
def description
def description "route #{@actual.inspect} to #{@expected.inspect}" end
def failure_message
def failure_message rescued_exception.message end
def failure_message_when_negated
def failure_message_when_negated "expected #{@actual.inspect} not to route to #{@expected.inspect}" end
def initialize(scope, *expected)
def initialize(scope, *expected) @scope = scope @expected = expected[1] || {} if Hash === expected[0] @expected.merge!(expected[0]) else controller, action = expected[0].split('#') @expected.merge!(controller: controller, action: action) end end
def matches?(verb_to_path_map)
def matches?(verb_to_path_map) @actual = verb_to_path_map # assert_recognizes does not consider ActionController::RoutingError an # assertion failure, so we have to capture that and Assertion here. match_unless_raises ActiveSupport::TestCase::Assertion, ActionController::RoutingError do path, query = *verb_to_path_map.values.first.split('?') @scope.assert_recognizes( @expected, { method: verb_to_path_map.keys.first, path: path }, Rack::Utils.parse_nested_query(query) ) end end