Class: Pact::Provider::Request::Replayable
- Inherits:
-
Object
- Object
- Pact::Provider::Request::Replayable
- Defined in:
- lib/pact/provider/request.rb
Constant Summary collapse
- NO_HTTP_PREFIX =
["CONTENT-TYPE", "CONTENT-LENGTH"]
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(expected_request, state_params = nil) ⇒ Replayable
constructor
A new instance of Replayable.
- #method ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(expected_request, state_params = nil) ⇒ Replayable
Returns a new instance of Replayable.
14 15 16 17 |
# File 'lib/pact/provider/request.rb', line 14 def initialize expected_request, state_params = nil @expected_request = expected_request @state_params = state_params end |
Instance Method Details
#body ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/pact/provider/request.rb', line 27 def body case expected_request.body when String then expected_request.body when NullExpectation then '' else Pact::Generators.apply_generators(expected_request, "body", reified_body, @state_params) end end |
#headers ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pact/provider/request.rb', line 36 def headers request_headers = {} # https://github.com/pact-foundation/pact-ruby/pull/327 request_headers.merge!('HOST' => 'localhost') if defined?(Sinatra) return request_headers if expected_request.headers.is_a?(Pact::NullExpectation) expected_request.headers.each do |key, value| request_headers[key] = Pact::Reification.from_term(value) end request_headers = Pact::Generators.apply_generators(expected_request, "header", request_headers, @state_params) request_headers.map{ |key,value| [rack_request_header_for(key), value]}.to_h end |
#method ⇒ Object
19 20 21 |
# File 'lib/pact/provider/request.rb', line 19 def method expected_request.method end |
#path ⇒ Object
23 24 25 |
# File 'lib/pact/provider/request.rb', line 23 def path Pact::Generators.apply_generators(expected_request, "path", expected_request.full_path, @state_params) end |