Class: Pact::InteractionV2Parser
- Inherits:
-
Object
- Object
- Pact::InteractionV2Parser
show all
- Includes:
- SymbolizeKeys
- Defined in:
- lib/pact/consumer_contract/interaction_v2_parser.rb
Class Method Summary
collapse
included, #symbolize_keys
Class Method Details
.call(hash, options) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 13
def self.call hash, options
request = parse_request(hash['request'], options)
response = parse_response(hash['response'], options)
provider_states = parse_provider_states(hash['providerState'] || hash['provider_state'])
metadata = parse_metadata(hash['metadata'])
Interaction.new(symbolize_keys(hash).merge(request: request,
response: response,
provider_states: provider_states,
metadata: metadata))
end
|
38
39
40
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 38
def self.parse_metadata metadata_hash
symbolize_keys(metadata_hash)
end
|
.parse_provider_states(provider_state_name) ⇒ Object
34
35
36
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 34
def self.parse_provider_states provider_state_name
provider_state_name ? [Pact::ProviderState.new(provider_state_name)] : []
end
|
.parse_request(request_hash, options) ⇒ Object
24
25
26
27
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 24
def self.parse_request request_hash, options
request_hash = Pact::MatchingRules.merge(request_hash, request_hash['matchingRules'], options)
Pact::Request::Expected.from_hash(request_hash)
end
|
.parse_response(response_hash, options) ⇒ Object
29
30
31
32
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 29
def self.parse_response response_hash, options
response_hash = Pact::MatchingRules.merge(response_hash, response_hash['matchingRules'], options)
Pact::Response.from_hash(response_hash)
end
|