class Shoulda::Matchers::ActionController::RouteMatcher
@private
def add_port_to_path(path, port)
def add_port_to_path(path, port) if port "https://example.com:#{port}" + path else path end end
def description
def description "route #{method.to_s.upcase} #{path} to/from #{params.inspect}" end
def failure_message_when_negated
def failure_message_when_negated "Didn't expect to #{description}" end
def guess_controller_if_necessary(controller)
def guess_controller_if_necessary(controller) params[:controller] ||= controller.controller_path end
def in_context(context)
def in_context(context) @context = context self end
def initialize(context, method, path, port: nil)
def initialize(context, method, path, port: nil) @context = context @method = method @path = add_port_to_path(normalize_path(path), port) @params = {} end
def matches?(controller)
def matches?(controller) guess_controller_if_necessary(controller) route_recognized? end
def normalize_path(path)
def normalize_path(path) if path.start_with?('/') path else "/#{path}" end end
def route_recognized?
def route_recognized? context.send( :assert_routing, { method: method, path: path }, params, ) true rescue ::ActionController::RoutingError => e @failure_message = e.message false rescue Shoulda::Matchers.assertion_exception_class => e @failure_message = e.message false end
def to(*args)
def to(*args) @params = RouteParams.new(args).normalize self end