class Faraday::Adapter::Test::Stub

rubocop:disable Style/StructInheritance
Stub request

def headers_match?(request_headers)

def headers_match?(request_headers)
  headers.keys.all? do |key|
    request_headers[key] == headers[key]
  end
end

def initialize(host, full, headers, body, block)

rubocop:enable Style/StructInheritance
def initialize(host, full, headers, body, block)
  path, query = full.respond_to?(:split) ? full.split('?') : full
  params =
    if query
      Faraday::Utils.parse_nested_query(query)
    else
      {}
    end
  super(host, path, params, headers, body, block)
end

def matches?(request_host, request_uri, request_headers, request_body)

def matches?(request_host, request_uri, request_headers, request_body)
  request_path, request_query = request_uri.split('?')
  request_params =
    if request_query
      Faraday::Utils.parse_nested_query(request_query)
    else
      {}
    end
  # meta is a hash used as carrier
  # that will be yielded to consumer block
  meta = {}
  [(host.nil? || host == request_host) &&
    path_match?(request_path, meta) &&
    params_match?(request_params) &&
    (body.to_s.size.zero? || request_body == body) &&
    headers_match?(request_headers), meta]
end

def params_match?(request_params)

def params_match?(request_params)
  params.keys.all? do |key|
    request_params[key] == params[key]
  end
end

def path_match?(request_path, meta)

def path_match?(request_path, meta)
  if path.is_a?(Regexp)
    !!(meta[:match_data] = path.match(request_path))
  else
    path == request_path
  end
end

def to_s

def to_s
  "#{path} #{body}"
end