module Faraday::ForTest::Response::Formatter
Public Instance Methods
request_body(pretty = false)
click to toggle source
TODO: configuraable
# File lib/faraday/for_test/response/formatter.rb, line 28 def request_body(pretty = false) if request_params && !request_params.empty? && !%i[ get delete ].include?(env[:method]) if formatter = Faraday::ForTest.configuration.body_formatters.find {|k, v| env[:request_headers]["Content-Type"] =~ /#{k}/ } formatter.last.call(request_params) else request_params.inspect end else "" end + "\n" end
request_headers()
click to toggle source
# File lib/faraday/for_test/response/formatter.rb, line 23 def request_headers env[:request_headers].map {|k, v| "#{k}: #{v}" }.join("\n") end
request_line()
click to toggle source
TODO: actual http version
# File lib/faraday/for_test/response/formatter.rb, line 19 def request_line [ env[:method].upcase, env[:url], "HTTP/1.1" ].join(" ") + "\n" end
response_body(pretty = false)
click to toggle source
# File lib/faraday/for_test/response/formatter.rb, line 49 def response_body(pretty = false) if body && !body.empty? if formatter = Faraday::ForTest.configuration.body_formatters.find {|k, v| headers["content-type"] =~ /#{k}/ } formatter.last.call(body) else body.inspect end else "" end + "\n" end
response_headers()
click to toggle source
# File lib/faraday/for_test/response/formatter.rb, line 45 def response_headers headers.map {|k, v| "#{k}: #{v}" }.join("\n") end
status_line()
click to toggle source
TODO: reason-phase
# File lib/faraday/for_test/response/formatter.rb, line 41 def status_line [ "HTTP/1.1", status ].join(" ") + "\n" end