pact-support 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/pact/consumer_contract/consumer_contract.rb +7 -2
- data/lib/pact/consumer_contract/interaction.rb +56 -89
- data/lib/pact/consumer_contract/interaction_parser.rb +23 -0
- data/lib/pact/consumer_contract/interaction_v2_parser.rb +28 -0
- data/lib/pact/consumer_contract/interaction_v3_parser.rb +61 -0
- data/lib/pact/consumer_contract/pact_file.rb +2 -2
- data/lib/pact/consumer_contract/string_with_matching_rules.rb +17 -0
- data/lib/pact/reification.rb +3 -0
- data/lib/pact/specification_version.rb +1 -1
- data/lib/pact/support/version.rb +1 -1
- data/spec/fixtures/not-a-pact.json +3 -0
- data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +20 -0
- data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +62 -0
- data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -23
- data/spec/lib/pact/reification_spec.rb +8 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d403d886a68ff8d7dcc27760407ae9c38328347
|
4
|
+
data.tar.gz: abbf6ec8fe5c0aef4d88c27861206e3ad8911a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 784021ebd38e3b04a2ce10078af2dd1575a80a66a6e3d10008086725407c3f2a568b41be3a7198ff5d7f52c70979c1cb034d601cd1bcdf0ab482d15da0c8da48
|
7
|
+
data.tar.gz: 13b5f238474aa903389b9252a76c71c0d6b416dbab8642571ac60d55100017dab53c98bd2d4b6056fe45922dba69e1984026ed6cea398a89ccf6d06269c69ea4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
<a name="v1.6.5"></a>
|
2
|
+
### v1.6.5 (2018-07-23)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* use 0 as the nil pact specification version ([88e4750](/../../commit/88e4750))
|
8
|
+
* reify StringWithMatchingRules to a String ([a025dd3](/../../commit/a025dd3))
|
9
|
+
* parse String response and request bodies to StringWithMatchingRules to support pact-xml ([a9fbb58](/../../commit/a9fbb58))
|
10
|
+
* add custom contract parsers to front of pact parsers list so that customised parsers are tried first ([babc319](/../../commit/babc319))
|
11
|
+
|
12
|
+
|
13
|
+
#### Bug Fixes
|
14
|
+
|
15
|
+
* show a more helpful error when attempting to parse a URI that is not a pact ([a8ba1ed](/../../commit/a8ba1ed))
|
16
|
+
|
17
|
+
|
1
18
|
<a name="v1.6.4"></a>
|
2
19
|
### v1.6.4 (2018-07-14)
|
3
20
|
|
@@ -13,6 +13,9 @@ require 'pact/consumer_contract/pact_file'
|
|
13
13
|
require 'pact/consumer_contract/http_consumer_contract_parser'
|
14
14
|
|
15
15
|
module Pact
|
16
|
+
|
17
|
+
class UnrecognizePactFormatError < ::Pact::Error; end
|
18
|
+
|
16
19
|
class ConsumerContract
|
17
20
|
|
18
21
|
include SymbolizeKeys
|
@@ -30,7 +33,7 @@ module Pact
|
|
30
33
|
end
|
31
34
|
|
32
35
|
def self.add_parser consumer_contract_parser
|
33
|
-
parsers
|
36
|
+
parsers.unshift(consumer_contract_parser)
|
34
37
|
end
|
35
38
|
|
36
39
|
def self.parsers
|
@@ -41,7 +44,7 @@ module Pact
|
|
41
44
|
parsers.each do | parser |
|
42
45
|
return parser.call(hash) if parser.can_parse?(hash)
|
43
46
|
end
|
44
|
-
raise Pact::
|
47
|
+
raise Pact::UnrecognizePactFormatError.new("This document does not use a recognised Pact format: #{hash}")
|
45
48
|
end
|
46
49
|
|
47
50
|
def self.from_json string
|
@@ -51,6 +54,8 @@ module Pact
|
|
51
54
|
|
52
55
|
def self.from_uri uri, options = {}
|
53
56
|
from_json(Pact::PactFile.read(uri, options))
|
57
|
+
rescue UnrecognizePactFormatError
|
58
|
+
raise Pact::UnrecognizePactFormatError.new("This document does not use a recognised Pact format. Please check that #{uri} is a valid pact file.")
|
54
59
|
end
|
55
60
|
|
56
61
|
def self.maintain_backwards_compatiblity_with_producer_keys string
|
@@ -1,104 +1,71 @@
|
|
1
|
-
require 'pact/consumer_contract/request'
|
2
|
-
require 'pact/consumer_contract/response'
|
3
|
-
require 'pact/symbolize_keys'
|
4
1
|
require 'pact/shared/active_support_support'
|
5
|
-
require 'pact/
|
6
|
-
require 'pact/errors'
|
7
|
-
require 'pact/specification_version'
|
2
|
+
require 'pact/consumer_contract/interaction_parser'
|
8
3
|
|
9
4
|
module Pact
|
10
5
|
class Interaction
|
11
6
|
include ActiveSupportSupport
|
12
|
-
include SymbolizeKeys
|
13
7
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
8
|
+
attr_accessor :description, :request, :response, :provider_state
|
9
|
+
|
10
|
+
def initialize attributes = {}
|
11
|
+
@description = attributes[:description]
|
12
|
+
@request = attributes[:request]
|
13
|
+
@response = attributes[:response]
|
14
|
+
@provider_state = attributes[:provider_state] || attributes[:providerState]
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.from_hash hash, options = {}
|
18
|
+
InteractionParser.call(hash, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_hash
|
22
|
+
{
|
23
|
+
description: description,
|
24
|
+
provider_state: provider_state,
|
25
|
+
request: request.to_hash,
|
26
|
+
response: response.to_hash
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def http?
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate!
|
35
|
+
raise Pact::InvalidInteractionError.new(self) unless description && request && response
|
36
|
+
end
|
37
|
+
|
38
|
+
def matches_criteria? criteria
|
39
|
+
criteria.each do | key, value |
|
40
|
+
unless match_criterion self.send(key.to_s), value
|
41
|
+
return false
|
28
42
|
end
|
29
43
|
end
|
44
|
+
true
|
45
|
+
end
|
30
46
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
response_hash = Pact::MatchingRules.merge(hash['response'], hash['response']['matchingRules'], options)
|
35
|
-
response = Pact::Response.from_hash(response_hash)
|
36
|
-
new(symbolize_keys(hash).merge(request: request, response: response))
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.parse_v3_interaction hash, options
|
40
|
-
|
41
|
-
request_hash = hash['request'].keys.each_with_object({}) do | key, new_hash |
|
42
|
-
new_hash[key] = Pact::MatchingRules.merge(hash['request'][key], hash['request'].fetch('matchingRules', {})[key], options)
|
43
|
-
end
|
44
|
-
request = Pact::Request::Expected.from_hash(request_hash)
|
45
|
-
|
46
|
-
response_hash = hash['response'].keys.each_with_object({}) do | key, new_hash |
|
47
|
-
new_hash[key] = Pact::MatchingRules.merge(hash['response'][key], hash['response'].fetch('matchingRules', {})[key], options)
|
48
|
-
end
|
47
|
+
def match_criterion target, criterion
|
48
|
+
target == criterion || (criterion.is_a?(Regexp) && criterion.match(target))
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
51
|
+
def == other
|
52
|
+
other.is_a?(Interaction) && to_hash == other.to_hash
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
provider_state: provider_state,
|
58
|
-
request: request.to_hash,
|
59
|
-
response: response.to_hash
|
60
|
-
}
|
61
|
-
end
|
55
|
+
def eq? other
|
56
|
+
self == other
|
57
|
+
end
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
def description_with_provider_state_quoted
|
60
|
+
provider_state ? "\"#{description}\" given \"#{provider_state}\"" : "\"#{description}\""
|
61
|
+
end
|
66
62
|
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
def request_modifies_resource_without_checking_response_body?
|
64
|
+
request.modifies_resource? && response.body_allows_any_value?
|
65
|
+
end
|
70
66
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
77
|
-
true
|
78
|
-
end
|
79
|
-
|
80
|
-
def match_criterion target, criterion
|
81
|
-
target == criterion || (criterion.is_a?(Regexp) && criterion.match(target))
|
82
|
-
end
|
83
|
-
|
84
|
-
def == other
|
85
|
-
other.is_a?(Interaction) && to_hash == other.to_hash
|
86
|
-
end
|
87
|
-
|
88
|
-
def eq? other
|
89
|
-
self == other
|
90
|
-
end
|
91
|
-
|
92
|
-
def description_with_provider_state_quoted
|
93
|
-
provider_state ? "\"#{description}\" given \"#{provider_state}\"" : "\"#{description}\""
|
94
|
-
end
|
95
|
-
|
96
|
-
def request_modifies_resource_without_checking_response_body?
|
97
|
-
request.modifies_resource? && response.body_allows_any_value?
|
98
|
-
end
|
99
|
-
|
100
|
-
def to_s
|
101
|
-
to_hash.to_s
|
102
|
-
end
|
103
|
-
end
|
67
|
+
def to_s
|
68
|
+
to_hash.to_s
|
69
|
+
end
|
70
|
+
end
|
104
71
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pact/specification_version'
|
2
|
+
require 'pact/consumer_contract/interaction_v2_parser'
|
3
|
+
require 'pact/consumer_contract/interaction_v3_parser'
|
4
|
+
|
5
|
+
module Pact
|
6
|
+
class InteractionParser
|
7
|
+
def self.call hash, options = {}
|
8
|
+
pact_specification_version = options[:pact_specification_version] || Pact::SpecificationVersion::NIL_VERSION
|
9
|
+
case pact_specification_version.major
|
10
|
+
when nil, 0, 1, 2 then parse_v2_interaction(hash, pact_specification_version: pact_specification_version)
|
11
|
+
else parse_v3_interaction(hash, pact_specification_version: pact_specification_version)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.parse_v2_interaction hash, options
|
16
|
+
InteractionV2Parser.call(hash, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parse_v3_interaction hash, options
|
20
|
+
InteractionV3Parser.call(hash, options)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'pact/consumer_contract/request'
|
2
|
+
require 'pact/consumer_contract/response'
|
3
|
+
require 'pact/symbolize_keys'
|
4
|
+
require 'pact/matching_rules'
|
5
|
+
require 'pact/errors'
|
6
|
+
|
7
|
+
module Pact
|
8
|
+
class InteractionV2Parser
|
9
|
+
|
10
|
+
include SymbolizeKeys
|
11
|
+
|
12
|
+
def self.call hash, options
|
13
|
+
request = parse_request(hash['request'], options)
|
14
|
+
response = parse_response(hash['response'], options)
|
15
|
+
Interaction.new(symbolize_keys(hash).merge(request: request, response: response))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.parse_request request_hash, options
|
19
|
+
request_hash = Pact::MatchingRules.merge(request_hash, request_hash['matchingRules'], options)
|
20
|
+
Pact::Request::Expected.from_hash(request_hash)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.parse_response response_hash, options
|
24
|
+
response_hash = Pact::MatchingRules.merge(response_hash, response_hash['matchingRules'], options)
|
25
|
+
Pact::Response.from_hash(response_hash)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'pact/consumer_contract/request'
|
2
|
+
require 'pact/consumer_contract/response'
|
3
|
+
require 'pact/symbolize_keys'
|
4
|
+
require 'pact/matching_rules'
|
5
|
+
require 'pact/errors'
|
6
|
+
require 'pact/consumer_contract/string_with_matching_rules'
|
7
|
+
|
8
|
+
module Pact
|
9
|
+
class InteractionV3Parser
|
10
|
+
|
11
|
+
include SymbolizeKeys
|
12
|
+
|
13
|
+
def self.call hash, options
|
14
|
+
request = parse_request(hash['request'], options)
|
15
|
+
response = parse_response(hash['response'], options)
|
16
|
+
Interaction.new(symbolize_keys(hash).merge(request: request, response: response))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parse_request request_hash, options
|
20
|
+
request_matching_rules = request_hash['matchingRules'] || {}
|
21
|
+
if request_hash['body'].is_a?(String)
|
22
|
+
parse_request_with_string_body(request_hash, request_matching_rules['body'] || {}, options)
|
23
|
+
else
|
24
|
+
parse_request_with_non_string_body(request_hash, request_matching_rules, options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse_response response_hash, options
|
29
|
+
response_matching_rules = response_hash['matchingRules'] || {}
|
30
|
+
if response_hash['body'].is_a?(String)
|
31
|
+
parse_response_with_string_body(response_hash, response_matching_rules['body'] || {}, options)
|
32
|
+
else
|
33
|
+
parse_response_with_non_string_body(response_hash, response_matching_rules, options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parse_request_with_non_string_body request_hash, request_matching_rules, options
|
38
|
+
request_hash = request_hash.keys.each_with_object({}) do | key, new_hash |
|
39
|
+
new_hash[key] = Pact::MatchingRules.merge(request_hash[key], request_matching_rules[key], options)
|
40
|
+
end
|
41
|
+
Pact::Request::Expected.from_hash(request_hash)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.parse_response_with_non_string_body response_hash, response_matching_rules, options
|
45
|
+
response_hash = response_hash.keys.each_with_object({}) do | key, new_hash |
|
46
|
+
new_hash[key] = Pact::MatchingRules.merge(response_hash[key], response_matching_rules[key], options)
|
47
|
+
end
|
48
|
+
Pact::Response.from_hash(response_hash)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.parse_request_with_string_body request_hash, request_matching_rules, options
|
52
|
+
string_with_matching_rules = StringWithMatchingRules.new(request_hash['body'], options[:pact_specification_version], request_matching_rules)
|
53
|
+
Pact::Request::Expected.from_hash(request_hash.merge('body' => string_with_matching_rules))
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.parse_response_with_string_body response_hash, response_matching_rules, options
|
57
|
+
string_with_matching_rules = StringWithMatchingRules.new(response_hash['body'], options[:pact_specification_version], response_matching_rules)
|
58
|
+
Pact::Response.from_hash(response_hash.merge('body' => string_with_matching_rules))
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -40,7 +40,7 @@ module Pact
|
|
40
40
|
end
|
41
41
|
|
42
42
|
private
|
43
|
-
|
43
|
+
|
44
44
|
def local? uri
|
45
45
|
!uri.start_with?("http://", "https://")
|
46
46
|
end
|
@@ -74,7 +74,7 @@ module Pact
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def get_remote(uri, options)
|
79
79
|
request = Net::HTTP::Get.new(uri)
|
80
80
|
request.basic_auth(options[:username], options[:password]) if options[:username]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Pact
|
2
|
+
class StringWithMatchingRules < String
|
3
|
+
attr_reader :matching_rules
|
4
|
+
attr_reader :pact_specification_version
|
5
|
+
|
6
|
+
def initialize string, pact_specification_version, matching_rules = {}
|
7
|
+
super(string)
|
8
|
+
@matching_rules = matching_rules
|
9
|
+
@pact_specification_version = pact_specification_version
|
10
|
+
end
|
11
|
+
|
12
|
+
# How can we show the matching rules too?
|
13
|
+
def to_s
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/pact/reification.rb
CHANGED
@@ -5,6 +5,7 @@ require 'pact/array_like'
|
|
5
5
|
require 'pact/shared/request'
|
6
6
|
require 'pact/consumer_contract/query_hash'
|
7
7
|
require 'pact/consumer_contract/query_string'
|
8
|
+
require 'pact/consumer_contract/string_with_matching_rules'
|
8
9
|
|
9
10
|
module Pact
|
10
11
|
module Reification
|
@@ -35,6 +36,8 @@ module Pact
|
|
35
36
|
"#{k}=#{escape(v)}"
|
36
37
|
end
|
37
38
|
}.join('&')
|
39
|
+
when Pact::StringWithMatchingRules
|
40
|
+
String.new(term)
|
38
41
|
else
|
39
42
|
term
|
40
43
|
end
|
data/lib/pact/support/version.rb
CHANGED
@@ -3,6 +3,26 @@ require 'pact/consumer_contract'
|
|
3
3
|
|
4
4
|
module Pact
|
5
5
|
describe ConsumerContract do
|
6
|
+
describe "from_uri" do
|
7
|
+
context "when the URL does not point to a valid pact" do
|
8
|
+
subject { ConsumerContract.from_uri('spec/fixtures/not-a-pact.json') }
|
9
|
+
|
10
|
+
it "raises a helpful error" do
|
11
|
+
expect { subject }.to raise_error UnrecognizePactFormatError, /Please check that spec/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "from_hash" do
|
17
|
+
context "when the hash is not a valid pact" do
|
18
|
+
subject { ConsumerContract.from_hash({'foo' => 'bar'}) }
|
19
|
+
|
20
|
+
it "raises a helpful error" do
|
21
|
+
expect { subject }.to raise_error UnrecognizePactFormatError, 'This document does not use a recognised Pact format: {"foo"=>"bar"}'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
6
26
|
describe ".from_json" do
|
7
27
|
|
8
28
|
let(:loaded_pact) { ConsumerContract.from_json(string) }
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'pact/consumer_contract/interaction_parser'
|
2
|
+
|
3
|
+
module Pact
|
4
|
+
describe InteractionParser do
|
5
|
+
describe ".call" do
|
6
|
+
|
7
|
+
let(:request) { {method: 'get', path: 'path'} }
|
8
|
+
let(:response) { {} }
|
9
|
+
|
10
|
+
context "when providerState has been used instead of provider_state" do
|
11
|
+
|
12
|
+
subject { InteractionParser.call('response' => response, 'request' => request, 'providerState' => 'some state') }
|
13
|
+
|
14
|
+
it "recognises the provider state" do
|
15
|
+
expect(subject.provider_state).to eq 'some state'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when there are matching rules" do
|
20
|
+
let(:hash) { load_json_fixture 'interaction-with-matching-rules.json' }
|
21
|
+
|
22
|
+
subject { InteractionParser.call(hash, pact_specification_version: Pact::SpecificationVersion.new("2")) }
|
23
|
+
|
24
|
+
it "merges the rules with the example for the request" do
|
25
|
+
expect(subject.request.body['name']).to be_instance_of(Pact::Term)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "merges the rules with the example for the response" do
|
29
|
+
expect(subject.response.body['_links']['self']['href']).to be_instance_of(Pact::Term)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when the request body is a String" do
|
34
|
+
let(:hash) { { 'request' => request, 'response' => response } }
|
35
|
+
subject { InteractionParser.call(hash, pact_specification_version: Pact::SpecificationVersion.new("3")) }
|
36
|
+
|
37
|
+
let(:request) { { 'method' => 'get', 'path' => 'path' , 'body' => "<xml></xml>", 'matchingRules' => {"body" => {"foo" => "bar"} } } }
|
38
|
+
|
39
|
+
it "returns an interaction with an StringWithMatchingRules in the request" do
|
40
|
+
expect(subject.request.body).to be_a(Pact::StringWithMatchingRules)
|
41
|
+
expect(subject.request.body).to eq "<xml></xml>"
|
42
|
+
expect(subject.request.body.matching_rules).to eq "foo" => "bar"
|
43
|
+
expect(subject.request.body.pact_specification_version).to eq Pact::SpecificationVersion.new("3")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when the response body is a String" do
|
48
|
+
let(:hash) { { 'request' => request, 'response' => response } }
|
49
|
+
subject { InteractionParser.call(hash, pact_specification_version: Pact::SpecificationVersion.new("3")) }
|
50
|
+
|
51
|
+
let(:response) { { 'status' => '200', 'body' => "<xml></xml>", 'matchingRules' => {"body" => {"foo" => "bar"} } } }
|
52
|
+
|
53
|
+
it "returns an interaction with an StringWithMatchingRules in the response" do
|
54
|
+
expect(subject.response.body).to be_a(Pact::StringWithMatchingRules)
|
55
|
+
expect(subject.response.body).to eq "<xml></xml>"
|
56
|
+
expect(subject.response.body.matching_rules).to eq "foo" => "bar"
|
57
|
+
expect(subject.response.body.pact_specification_version).to eq Pact::SpecificationVersion.new("3")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -52,30 +52,7 @@ module Pact
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe "from_hash" do
|
56
|
-
context "when providerState has been used instead of provider_state" do
|
57
55
|
|
58
|
-
subject { Interaction.from_hash('response' => response, 'request' => request, 'providerState' => 'some state') }
|
59
|
-
|
60
|
-
it "recognises the provider state" do
|
61
|
-
expect(subject.provider_state).to eq 'some state'
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context "when there are matching rules" do
|
66
|
-
let(:hash) { load_json_fixture 'interaction-with-matching-rules.json' }
|
67
|
-
|
68
|
-
subject { Interaction.from_hash hash, pact_specification_version: Pact::SpecificationVersion.new("2") }
|
69
|
-
|
70
|
-
it "merges the rules with the example for the request" do
|
71
|
-
expect(subject.request.body['name']).to be_instance_of(Pact::Term)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "merges the rules with the example for the response" do
|
75
|
-
expect(subject.response.body['_links']['self']['href']).to be_instance_of(Pact::Term)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
56
|
|
80
57
|
describe "request_modifies_resource_without_checking_response_body?" do
|
81
58
|
|
@@ -160,5 +160,13 @@ module Pact
|
|
160
160
|
expect(subject).to eq("param=1¶m=1")
|
161
161
|
end
|
162
162
|
end
|
163
|
+
|
164
|
+
context "with a StringWithMatchingRules" do
|
165
|
+
subject { Reification.from_term(StringWithMatchingRules.new("foo", Pact::SpecificationVersion.new("3"), {}))}
|
166
|
+
|
167
|
+
it "returns a String" do
|
168
|
+
expect(subject.class).to be String
|
169
|
+
end
|
170
|
+
end
|
163
171
|
end
|
164
172
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Fraser
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2018-07-
|
15
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|
@@ -270,6 +270,9 @@ files:
|
|
270
270
|
- lib/pact/consumer_contract/headers.rb
|
271
271
|
- lib/pact/consumer_contract/http_consumer_contract_parser.rb
|
272
272
|
- lib/pact/consumer_contract/interaction.rb
|
273
|
+
- lib/pact/consumer_contract/interaction_parser.rb
|
274
|
+
- lib/pact/consumer_contract/interaction_v2_parser.rb
|
275
|
+
- lib/pact/consumer_contract/interaction_v3_parser.rb
|
273
276
|
- lib/pact/consumer_contract/pact_file.rb
|
274
277
|
- lib/pact/consumer_contract/query.rb
|
275
278
|
- lib/pact/consumer_contract/query_hash.rb
|
@@ -278,6 +281,7 @@ files:
|
|
278
281
|
- lib/pact/consumer_contract/response.rb
|
279
282
|
- lib/pact/consumer_contract/service_consumer.rb
|
280
283
|
- lib/pact/consumer_contract/service_provider.rb
|
284
|
+
- lib/pact/consumer_contract/string_with_matching_rules.rb
|
281
285
|
- lib/pact/errors.rb
|
282
286
|
- lib/pact/helpers.rb
|
283
287
|
- lib/pact/logging.rb
|
@@ -327,6 +331,7 @@ files:
|
|
327
331
|
- script/release.sh
|
328
332
|
- script/update-pact-specification-v2
|
329
333
|
- spec/fixtures/interaction-with-matching-rules.json
|
334
|
+
- spec/fixtures/not-a-pact.json
|
330
335
|
- spec/fixtures/pact-http-v2.json
|
331
336
|
- spec/fixtures/pact-http-v3.json
|
332
337
|
- spec/integration/matching_rules_extract_and_merge_spec.rb
|
@@ -338,6 +343,7 @@ files:
|
|
338
343
|
- spec/lib/pact/consumer_contract/file_name_spec.rb
|
339
344
|
- spec/lib/pact/consumer_contract/headers_spec.rb
|
340
345
|
- spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb
|
346
|
+
- spec/lib/pact/consumer_contract/interaction_parser_spec.rb
|
341
347
|
- spec/lib/pact/consumer_contract/interaction_spec.rb
|
342
348
|
- spec/lib/pact/consumer_contract/pact_file_spec.rb
|
343
349
|
- spec/lib/pact/consumer_contract/query_hash_spec.rb
|
@@ -430,6 +436,7 @@ specification_version: 4
|
|
430
436
|
summary: Shared code for Pact gems
|
431
437
|
test_files:
|
432
438
|
- spec/fixtures/interaction-with-matching-rules.json
|
439
|
+
- spec/fixtures/not-a-pact.json
|
433
440
|
- spec/fixtures/pact-http-v2.json
|
434
441
|
- spec/fixtures/pact-http-v3.json
|
435
442
|
- spec/integration/matching_rules_extract_and_merge_spec.rb
|
@@ -441,6 +448,7 @@ test_files:
|
|
441
448
|
- spec/lib/pact/consumer_contract/file_name_spec.rb
|
442
449
|
- spec/lib/pact/consumer_contract/headers_spec.rb
|
443
450
|
- spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb
|
451
|
+
- spec/lib/pact/consumer_contract/interaction_parser_spec.rb
|
444
452
|
- spec/lib/pact/consumer_contract/interaction_spec.rb
|
445
453
|
- spec/lib/pact/consumer_contract/pact_file_spec.rb
|
446
454
|
- spec/lib/pact/consumer_contract/query_hash_spec.rb
|