recognized_request_for(path, extras = {}, msg)
private
Recognizes the route for a given path.
# File actionpack/lib/action_dispatch/testing/assertions/routing.rb, line 177
def recognized_request_for(path, extras = {}, msg)
if path.is_a?(Hash)
method = path[:method]
path = path[:path]
else
method = :get
end
# Assume given controller
request = ActionController::TestRequest.new
if path =~ %{://}
fail_on(URI::InvalidURIError, msg) do
uri = URI.parse(path)
request.env["rack.url_scheme"] = uri.scheme || "http"
request.host = uri.host if uri.host
request.port = uri.port if uri.port
request.path = uri.path.to_s.empty? ? "/" : uri.path
end
else
path = "/#{path}" unless path.first == "/"
request.path = path
end
request.request_method = method if method
params = fail_on(ActionController::RoutingError, msg) do
@routes.recognize_path(path, { :method => method, :extras => extras })
end
request.path_parameters = params.with_indifferent_access
request
end