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

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

Constant Summary collapse

NO_HTTP_PREFIX =
["CONTENT-TYPE", "CONTENT-LENGTH"]

Instance Method Summary collapse

Constructor Details

#initialize(expected_request) ⇒ Replayable



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

def initialize expected_request
  @expected_request = expected_request
end

Instance Method Details

#bodyObject



25
26
27
28
29
30
31
32
# File 'lib/pact/provider/request.rb', line 25

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

#headersObject



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

def headers
  request_headers = {}
  return request_headers if expected_request.headers.is_a?(Pact::NullExpectation)
  expected_request.headers.each do |key, value|
    request_headers[rack_request_header_for(key)] = Pact::Reification.from_term(value)
  end
  request_headers
end

#methodObject



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

def method
  expected_request.method
end

#pathObject



21
22
23
# File 'lib/pact/provider/request.rb', line 21

def path
  expected_request.full_path
end