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
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 14
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
|
53
54
55
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 53
def self.parse_metadata metadata_hash
symbolize_keys(metadata_hash)
end
|
.parse_provider_states(provider_state_name) ⇒ Object
49
50
51
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 49
def self.parse_provider_states provider_state_name
provider_state_name ? [Pact::ProviderState.new(provider_state_name)] : []
end
|
.parse_request(request_hash, options) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 25
def self.parse_request request_hash, options
original_query_string = request_hash['query']
query_is_string = original_query_string.is_a?(String)
if query_is_string
request_hash = request_hash.dup
request_hash['query'] = Pact::Query.parse_string(request_hash['query'])
end
request_hash = Pact::MatchingRules.merge(request_hash, request_hash['matchingRules'], options)
if query_is_string
request_hash['query'] = Pact::QueryHash.new(request_hash['query'], original_query_string, Pact::Query.parsed_as_nested?(request_hash['query']))
end
Pact::Request::Expected.from_hash(request_hash)
end
|
.parse_response(response_hash, options) ⇒ Object
44
45
46
47
|
# File 'lib/pact/consumer_contract/interaction_v2_parser.rb', line 44
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
|