Class: Pact::Response
- Inherits:
-
Hash
- Object
- Hash
- Pact::Response
show all
- Includes:
- SymbolizeKeys
- Defined in:
- lib/pact/consumer_contract/response.rb
Class Method Summary
collapse
Instance Method Summary
collapse
included, #symbolize_keys
Constructor Details
#initialize(attributes) ⇒ Response
Returns a new instance of Response.
13
14
15
|
# File 'lib/pact/consumer_contract/response.rb', line 13
def initialize attributes
merge!(attributes.reject{|key, value| !ALLOWED_KEYS.include?(key)})
end
|
Class Method Details
.from_hash(hash) ⇒ Object
41
42
43
44
|
# File 'lib/pact/consumer_contract/response.rb', line 41
def self.from_hash hash
= Headers.new(hash[:headers] || hash['headers'] || {})
new(symbolize_keys(hash).merge(headers: ))
end
|
Instance Method Details
#[](key) ⇒ Object
37
38
39
|
# File 'lib/pact/consumer_contract/response.rb', line 37
def [] key
super key.to_sym
end
|
#body ⇒ Object
25
26
27
|
# File 'lib/pact/consumer_contract/response.rb', line 25
def body
self[:body]
end
|
#body_allows_any_value? ⇒ Boolean
33
34
35
|
# File 'lib/pact/consumer_contract/response.rb', line 33
def body_allows_any_value?
body_not_specified? || body_is_empty_hash?
end
|
21
22
23
|
# File 'lib/pact/consumer_contract/response.rb', line 21
def
self[:headers]
end
|
#specified?(key) ⇒ Boolean
29
30
31
|
# File 'lib/pact/consumer_contract/response.rb', line 29
def specified? key
self.key?(key.to_sym)
end
|
#status ⇒ Object
17
18
19
|
# File 'lib/pact/consumer_contract/response.rb', line 17
def status
self[:status]
end
|