class Pact::Response

Constants

ALLOWED_KEYS

Public Class Methods

from_hash(hash) click to toggle source
# File lib/pact/consumer_contract/response.rb, line 41
def self.from_hash hash
  headers = Headers.new(hash[:headers] || hash['headers'] || {})
  new(symbolize_keys(hash).merge(headers: headers))
end
new(attributes) click to toggle source
# File lib/pact/consumer_contract/response.rb, line 13
def initialize attributes
  merge!(attributes.reject{|key, value| !ALLOWED_KEYS.include?(key)})
end

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/pact/consumer_contract/response.rb, line 37
def [] key
  super key.to_sym
end
body() click to toggle source
# File lib/pact/consumer_contract/response.rb, line 25
def body
  self[:body]
end
body_allows_any_value?() click to toggle source
# File lib/pact/consumer_contract/response.rb, line 33
def body_allows_any_value?
  body_not_specified? || body_is_empty_hash?
end
headers() click to toggle source
# File lib/pact/consumer_contract/response.rb, line 21
def headers
  self[:headers]
end
specified?(key) click to toggle source
# File lib/pact/consumer_contract/response.rb, line 29
def specified? key
  self.key?(key.to_sym)
end
status() click to toggle source
# File lib/pact/consumer_contract/response.rb, line 17
def status
  self[:status]
end

Private Instance Methods

body_is_empty_hash?() click to toggle source
# File lib/pact/consumer_contract/response.rb, line 48
def body_is_empty_hash?
  body.is_a?(Hash) && body.empty?
end
body_not_specified?() click to toggle source
# File lib/pact/consumer_contract/response.rb, line 52
def body_not_specified?
  !specified?(:body)
end