class Pact::Provider::Request::Replayable
Constants
Attributes
expected_request[R]
Public Class Methods
new(expected_request)
click to toggle source
# File lib/pact/provider/request.rb, line 13 def initialize expected_request @expected_request = expected_request end
Public Instance Methods
body()
click to toggle source
# 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
headers()
click to toggle source
# 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
method()
click to toggle source
# File lib/pact/provider/request.rb, line 17 def method expected_request.method end
path()
click to toggle source
# File lib/pact/provider/request.rb, line 21 def path expected_request.full_path end
Private Instance Methods
rack_request_header_for(header)
click to toggle source
# File lib/pact/provider/request.rb, line 56 def rack_request_header_for header with_http_prefix(header.to_s.upcase).tr('-', '_') end
rack_request_value_for(value)
click to toggle source
# File lib/pact/provider/request.rb, line 60 def rack_request_value_for value Array(value).join("\n") end
reified_body()
click to toggle source
# File lib/pact/provider/request.rb, line 47 def reified_body rb = Pact::Reification.from_term(expected_request.body) if rb.is_a?(String) rb else JSON.dump(rb) end end
with_http_prefix(header)
click to toggle source
# File lib/pact/provider/request.rb, line 64 def with_http_prefix header NO_HTTP_PREFIX.include?(header) ? header : "HTTP_#{header}" end