pact-support 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/pact/matching_rules/merge.rb +6 -5
- data/lib/pact/support/version.rb +1 -1
- data/spec/lib/pact/matching_rules/merge_spec.rb +64 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ea2875d5e2dc8777d847b774ec40a0d4afd539e
|
4
|
+
data.tar.gz: 425177cb326444b96ed9d24081e6d8f02daefec4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce82242279a886e133d667a06e2202a81e009e8a4bd3c5c2f2a904f849421af09ec7a1159be83370806b247e7fda0404efe0568121c294cd74dfb068e9137085
|
7
|
+
data.tar.gz: 0efae033f755ab785ec05e91a3acf8e9b732991374115ea879bebf4f75ea27bec34655914ec2756d0ebe6fd68a2fdedc5affc9acba1a656a916ca91e62d638c1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
git log --pretty=format:' * %h - %s (%an, %ad)'
|
4
4
|
|
5
|
+
### 1.1.5 (1 Aug 2017)
|
6
|
+
* 81bc967 - fix(match type rules): Allow match: 'type' to be specified on the parent element of the array. Closes: #35, https://github.com/pact-foundation/pact-provider-verifier/issues/8 (Beth Skurrie, Tue Aug 1 10:33:02 2017 +1000)
|
7
|
+
|
5
8
|
### 1.1.4 (31 July 2017)
|
6
9
|
* 425881c - fix(cirular dependency for UnixDiffFormatter): Fixes circular dependency between pact/configuration and pact/matchers/unix_diff_formatter (Beth Skurrie, Mon Jul 31 11:45:44 2017 +1000)
|
7
10
|
|
@@ -46,12 +46,13 @@ module Pact
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def recurse_array array, path
|
49
|
-
|
50
|
-
|
49
|
+
array_like_children_path = "#{path}[*]*"
|
50
|
+
parent_match_rule = @matching_rules[path] && @matching_rules[path]['match']
|
51
|
+
children_match_rule = @matching_rules[array_like_children_path] && @matching_rules[array_like_children_path]['match']
|
52
|
+
min = @matching_rules[path] && @matching_rules[path]['min']
|
51
53
|
|
52
|
-
if
|
54
|
+
if min && (children_match_rule == 'type' || (children_match_rule.nil? && parent_match_rule == 'type'))
|
53
55
|
warn_when_not_one_example_item(array, path)
|
54
|
-
min = @matching_rules[path]['min']
|
55
56
|
# log_ignored_rules(path, @matching_rules[path], {'min' => min})
|
56
57
|
Pact::ArrayLike.new(recurse(array.first, "#{path}[*]"), min: min)
|
57
58
|
else
|
@@ -75,7 +76,7 @@ module Pact
|
|
75
76
|
array_rules = @matching_rules["#{path}[*]*"]
|
76
77
|
return object unless rules || array_rules
|
77
78
|
|
78
|
-
if rules['match'] == 'type'
|
79
|
+
if rules['match'] == 'type' && !rules.has_key?('min')
|
79
80
|
handle_match_type(object, path, rules)
|
80
81
|
elsif rules['regex']
|
81
82
|
handle_regex(object, path, rules)
|
data/lib/pact/support/version.rb
CHANGED
@@ -104,11 +104,13 @@ module Pact
|
|
104
104
|
"$.body._links.self.href" => { "regex" => "http:\\/\\/.*\\/thing", "match" => "regex", "ignored" => "somerule" }
|
105
105
|
}
|
106
106
|
end
|
107
|
+
|
107
108
|
it "creates a Pact::Term at the appropriate path" do
|
108
109
|
expect(subject["_links"]["self"]["href"]).to be_instance_of(Pact::Term)
|
109
110
|
expect(subject["_links"]["self"]["href"].generate).to eq "http://localhost:1234/thing"
|
110
111
|
expect(subject["_links"]["self"]["href"].matcher.inspect).to eq "/http:\\/\\/.*\\/thing/"
|
111
112
|
end
|
113
|
+
|
112
114
|
it "it logs the rules it has ignored" do
|
113
115
|
expect($stderr).to receive(:puts) do | message |
|
114
116
|
expect(message).to match /ignored.*"somerule"/
|
@@ -136,6 +138,7 @@ module Pact
|
|
136
138
|
"$.body._links.self[0].href" => { "regex" => "http:\\/\\/.*\\/thing" }
|
137
139
|
}
|
138
140
|
end
|
141
|
+
|
139
142
|
it "creates a Pact::Term at the appropriate path" do
|
140
143
|
expect(subject["_links"]["self"][0]["href"]).to be_instance_of(Pact::Term)
|
141
144
|
expect(subject["_links"]["self"][0]["href"].generate).to eq "http://localhost:1234/thing"
|
@@ -143,14 +146,29 @@ module Pact
|
|
143
146
|
end
|
144
147
|
end
|
145
148
|
|
146
|
-
describe "with an array where all elements should match by type" do
|
149
|
+
describe "with an array where all elements should match by type and the rule is specified on the parent element and there is no min specified" do
|
147
150
|
let(:expected) do
|
148
151
|
{
|
152
|
+
'alligators' => [{'name' => 'Mary'}]
|
153
|
+
}
|
154
|
+
end
|
149
155
|
|
150
|
-
|
151
|
-
|
152
|
-
|
156
|
+
let(:matching_rules) do
|
157
|
+
{
|
158
|
+
"$.body.alligators" => { 'match' => 'type' }
|
159
|
+
}
|
160
|
+
end
|
161
|
+
|
162
|
+
it "creates a Pact::SomethingLike at the appropriate path" do
|
163
|
+
expect(subject["alligators"]).to be_instance_of(Pact::SomethingLike)
|
164
|
+
expect(subject["alligators"].contents).to eq ['name' => 'Mary']
|
165
|
+
end
|
166
|
+
end
|
153
167
|
|
168
|
+
describe "with an array where all elements should match by type and the rule is specified on the child elements" do
|
169
|
+
let(:expected) do
|
170
|
+
{
|
171
|
+
'alligators' => [{'name' => 'Mary'}]
|
154
172
|
}
|
155
173
|
end
|
156
174
|
|
@@ -167,6 +185,47 @@ module Pact
|
|
167
185
|
end
|
168
186
|
end
|
169
187
|
|
188
|
+
describe "with an array where all elements should match by type and the rule is specified on both the parent element and the child elements" do
|
189
|
+
let(:expected) do
|
190
|
+
{
|
191
|
+
'alligators' => [{'name' => 'Mary'}]
|
192
|
+
}
|
193
|
+
end
|
194
|
+
|
195
|
+
let(:matching_rules) do
|
196
|
+
{
|
197
|
+
"$.body.alligators" => { 'min' => 2, 'match' => 'type' },
|
198
|
+
"$.body.alligators[*].*" => { 'match' => 'type'}
|
199
|
+
}
|
200
|
+
end
|
201
|
+
|
202
|
+
it "creates a Pact::ArrayLike at the appropriate path" do
|
203
|
+
expect(subject["alligators"]).to be_instance_of(Pact::ArrayLike)
|
204
|
+
expect(subject["alligators"].contents).to eq 'name' => 'Mary'
|
205
|
+
expect(subject["alligators"].min).to eq 2
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "with an array where all elements should match by type and there is only a match:type on the parent element" do
|
210
|
+
let(:expected) do
|
211
|
+
{
|
212
|
+
'alligators' => [{'name' => 'Mary'}]
|
213
|
+
}
|
214
|
+
end
|
215
|
+
|
216
|
+
let(:matching_rules) do
|
217
|
+
{
|
218
|
+
"$.body.alligators" => { 'min' => 2, 'match' => 'type' },
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
it "creates a Pact::ArrayLike at the appropriate path" do
|
223
|
+
expect(subject["alligators"]).to be_instance_of(Pact::ArrayLike)
|
224
|
+
expect(subject["alligators"].contents).to eq 'name' => 'Mary'
|
225
|
+
expect(subject["alligators"].min).to eq 2
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
170
229
|
describe "with an array where all elements should match by type nested inside another array where all elements should match by type" do
|
171
230
|
let(:expected) do
|
172
231
|
{
|
@@ -191,6 +250,7 @@ module Pact
|
|
191
250
|
"$.body.alligators[*].children[*].*" => { 'match' => 'type'}
|
192
251
|
}
|
193
252
|
end
|
253
|
+
|
194
254
|
it "creates a Pact::ArrayLike at the appropriate path" do
|
195
255
|
expect(subject["alligators"].contents['children']).to be_instance_of(Pact::ArrayLike)
|
196
256
|
expect(subject["alligators"].contents['children'].contents).to eq 'age' => 9
|
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.1.
|
4
|
+
version: 1.1.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: 2017-
|
15
|
+
date: 2017-08-01 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|