Class: Pact::Provider::Request::Replayable

Inherits:
Object
  • Object
show all
Defined in:
lib/pact/provider/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected_request) ⇒ Replayable

Returns a new instance of Replayable.



10
11
12
# File 'lib/pact/provider/request.rb', line 10

def initialize expected_request
  @expected_request = expected_request
end

Instance Method Details

#bodyObject



22
23
24
25
26
27
28
29
# File 'lib/pact/provider/request.rb', line 22

def body
  case expected_request.body
  when String then expected_request.body
  when NullExpectation then ''
  else
    reified_body
  end
end

#headersObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/pact/provider/request.rb', line 31

def headers
  request_headers = {}
  return request_headers if expected_request.headers.is_a?(Pact::NullExpectation)
  expected_request.headers.each do |key, value|
    key = key.upcase
    if key.match(/CONTENT.TYPE/)
      request_headers['CONTENT_TYPE'] = value
    else
      request_headers[formatted_request_header_key(key)] = value
    end
  end
  request_headers
end

#methodObject



14
15
16
# File 'lib/pact/provider/request.rb', line 14

def method
  expected_request.method
end

#pathObject



18
19
20
# File 'lib/pact/provider/request.rb', line 18

def path
  expected_request.full_path
end