module Faraday::ForTest::Response::Dumper

Public Class Methods

new(response, params = {}) click to toggle source

override

Calls superclass method
# File lib/faraday/for_test/response/dumper.rb, line 34
def initialize(response, params = {})
  super(response, params)
  dump_once if Faraday::ForTest.configuration.dump_always
end

Public Instance Methods

dump(pretty = true) click to toggle source

TODO: enable configuration

# File lib/faraday/for_test/response/dumper.rb, line 10
def dump(pretty = true)
  warn "-------- 8x [req] x8 --------"
  warn request_line
  warn request_headers
  warn "\n"
  warn request_body(pretty)
  warn "-------- 8x [res] x8 --------"
  warn status_line
  warn response_headers
  warn "\n"
  warn response_body(pretty)
  warn "-------- 8x [end] x8 --------"

  self
end
dump_once() click to toggle source
# File lib/faraday/for_test/response/dumper.rb, line 26
def dump_once
  dump unless @dumped
  @dumped = true

  self
end
must_succeed() click to toggle source

override assertion

Calls superclass method
# File lib/faraday/for_test/response/dumper.rb, line 40
def must_succeed
  begin
    super
  rescue Faraday::ForTest::Response::Assertion::AssertionError => e
    dump_once if Faraday::ForTest.configuration.dump_if_assert_failed
    raise e
  end
end