Module: Faraday::ForTest::Response::Dumper

Included in:
Faraday::ForTest::Response
Defined in:
lib/faraday/for_test/response/dumper.rb

Instance Method Summary collapse

Instance Method Details

#dump(pretty = true) ⇒ Object

TODO: enable configuration



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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_onceObject



26
27
28
29
30
31
# File 'lib/faraday/for_test/response/dumper.rb', line 26

def dump_once
  dump unless @dumped
  @dumped = true

  self
end

#initialize(response, params = {}) ⇒ Object

override



34
35
36
37
# 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

#must_succeedObject

override assertion



40
41
42
43
44
45
46
47
# 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