# File lib/faraday/adapter/test.rb, line 133 def initialize(host, full, headers, body, block) path, query = full.respond_to?(:split) ? full.split("?") : full params = query ? Faraday::Utils.parse_nested_query(query) : {} super(host, path, params, headers, body, block) end
# File lib/faraday/adapter/test.rb, line 170 def headers_match?(request_headers) headers.keys.all? do |key| request_headers[key] == headers[key] end end
# File lib/faraday/adapter/test.rb, line 141 def matches?(request_host, request_uri, request_headers, request_body) request_path, request_query = request_uri.split('?') request_params = request_query ? Faraday::Utils.parse_nested_query(request_query) : {} # meta is a hash use as carrier # that will be yielded to consumer block meta = {} return (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
# File lib/faraday/adapter/test.rb, line 164 def params_match?(request_params) params.keys.all? do |key| request_params[key] == params[key] end end
# File lib/faraday/adapter/test.rb, line 156 def path_match?(request_path, meta) if path.is_a? Regexp !!(meta[:match_data] = path.match(request_path)) else path == request_path end end
# File lib/faraday/adapter/test.rb, line 176 def to_s "#{path} #{body}" end