instance method recognized_request_for

Ruby on Rails 5.2.8.1

Since v3.0.20 Private

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

recognized_request_for(path, extras = {}, msg)

Recognizes the route for a given path.

Parameters

path req
extras opt = {}
msg req
Source
# File actionpack/lib/action_dispatch/testing/assertions/routing.rb, line 182
        def recognized_request_for(path, extras = {}, msg)
          if path.is_a?(Hash)
            method = path[:method]
            path   = path[:path]
          else
            method = :get
          end

          request = ActionController::TestRequest.create @controller.class

          if path =~ %r{://}
            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

Defined in actionpack/lib/action_dispatch/testing/assertions/routing.rb line 182 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::Assertions::RoutingAssertions

Type at least 2 characters to search.

↑↓ navigate · open · esc close