pact-support 1.6.2 → 1.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/pact/consumer_contract/query_hash.rb +2 -0
- data/lib/pact/matching_rules/merge.rb +29 -13
- data/lib/pact/support/version.rb +1 -1
- data/spec/lib/pact/consumer_contract/query_hash_spec.rb +14 -0
- data/spec/lib/pact/matching_rules/merge_spec.rb +20 -7
- 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: add17cb769a9dad8275e79e1320049e8134bfc0a
|
4
|
+
data.tar.gz: 92d453de103d3ee753736b80c0de57f4323b0725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8c8ccfc4a3a9884b600ac349ffbdb5eee0934867cedf32ae5f6a62919d573d6a383dae9ee675d471b425d6591bc1a0a07b2b1bee1729027ff5a8100963c14f
|
7
|
+
data.tar.gz: c81c6c65b68b03cb5867e0fc94bf6df9fd849a881fc9936b14c13ec73fea4d1d967e7fdb73b2b5e77208dbe04d0e1a9cfdfffe17f08d80a04b1706e67ba74fd4
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
<a name="v1.6.3"></a>
|
2
|
+
### v1.6.3 (2018-07-12)
|
3
|
+
|
4
|
+
|
5
|
+
#### Bug Fixes
|
6
|
+
|
7
|
+
* remove incorrect warning about ignoring unsupported matching rules for min => x ([50d5f6d](/../../commit/50d5f6d))
|
8
|
+
* serialize ArrayLike in query params without wrapping another array around it ([b4a9ec7](/../../commit/b4a9ec7))
|
9
|
+
|
10
|
+
|
1
11
|
<a name="v1.6.2"></a>
|
2
12
|
### v1.6.2 (2018-05-31)
|
3
13
|
|
@@ -13,11 +13,12 @@ module Pact
|
|
13
13
|
@expected = expected
|
14
14
|
@matching_rules = standardise_paths(matching_rules)
|
15
15
|
@root_path = JsonPath.new(root_path).to_s
|
16
|
+
@used_rules = []
|
16
17
|
end
|
17
18
|
|
18
19
|
def call
|
19
20
|
return @expected if @matching_rules.nil? || @matching_rules.empty?
|
20
|
-
recurse
|
21
|
+
recurse(@expected, @root_path).tap { log_ignored_rules }
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
@@ -46,14 +47,18 @@ module Pact
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def recurse_array array, path
|
50
|
+
parent_match_rule = find_rule(path, 'match')
|
51
|
+
log_used_rule(path, 'match', parent_match_rule) if parent_match_rule
|
52
|
+
|
49
53
|
array_like_children_path = "#{path}[*]*"
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
children_match_rule = find_rule(array_like_children_path, 'match')
|
55
|
+
log_used_rule(array_like_children_path, 'match', children_match_rule) if children_match_rule
|
56
|
+
|
57
|
+
min = find_rule(path, 'min')
|
58
|
+
log_used_rule(path, 'min', min) if min
|
53
59
|
|
54
60
|
if min && (children_match_rule == 'type' || (children_match_rule.nil? && parent_match_rule == 'type'))
|
55
61
|
warn_when_not_one_example_item(array, path)
|
56
|
-
# log_ignored_rules(path, @matching_rules[path], {'min' => min})
|
57
62
|
Pact::ArrayLike.new(recurse(array.first, "#{path}[*]"), min: min)
|
58
63
|
else
|
59
64
|
new_array = []
|
@@ -81,30 +86,41 @@ module Pact
|
|
81
86
|
elsif rules['regex']
|
82
87
|
handle_regex(object, path, rules)
|
83
88
|
else
|
84
|
-
log_ignored_rules(path, rules, {})
|
85
89
|
object
|
86
90
|
end
|
87
91
|
end
|
88
92
|
|
89
93
|
def handle_match_type object, path, rules
|
90
|
-
|
94
|
+
log_used_rule(path, 'match', 'type')
|
91
95
|
Pact::SomethingLike.new(object)
|
92
96
|
end
|
93
97
|
|
94
98
|
def handle_regex object, path, rules
|
95
|
-
|
99
|
+
log_used_rule(path, 'match', 'regex') # assumed to be present
|
100
|
+
log_used_rule(path, 'regex', rules['regex'])
|
96
101
|
Pact::Term.new(generate: object, matcher: Regexp.new(rules['regex']))
|
97
102
|
end
|
98
103
|
|
99
|
-
def log_ignored_rules
|
100
|
-
dup_rules =
|
101
|
-
used_rules.
|
102
|
-
dup_rules.delete(
|
104
|
+
def log_ignored_rules
|
105
|
+
dup_rules = @matching_rules.dup
|
106
|
+
@used_rules.each do | (path, key, value) |
|
107
|
+
dup_rules[path].delete(key) if dup_rules[path][key] == value
|
103
108
|
end
|
109
|
+
|
104
110
|
if dup_rules.any?
|
105
|
-
|
111
|
+
dup_rules.each do | path, rules |
|
112
|
+
$stderr.puts "WARN: Ignoring unsupported matching rules #{rules} for path #{path}" if rules.any?
|
113
|
+
end
|
106
114
|
end
|
107
115
|
end
|
116
|
+
|
117
|
+
def find_rule(path, key)
|
118
|
+
@matching_rules[path] && @matching_rules[path][key]
|
119
|
+
end
|
120
|
+
|
121
|
+
def log_used_rule path, key, value
|
122
|
+
@used_rules << [path, key, value]
|
123
|
+
end
|
108
124
|
end
|
109
125
|
end
|
110
126
|
end
|
data/lib/pact/support/version.rb
CHANGED
@@ -82,6 +82,20 @@ module Pact
|
|
82
82
|
end
|
83
83
|
|
84
84
|
describe "#to_json" do
|
85
|
+
context "when the query contains an ArrayLike" do
|
86
|
+
let(:query) { { foo: Pact.each_like("1"), bar: "2" } }
|
87
|
+
let(:expected_json) do
|
88
|
+
{
|
89
|
+
foo: Pact.each_like("1"),
|
90
|
+
bar: ["2"]
|
91
|
+
}.to_json
|
92
|
+
end
|
93
|
+
|
94
|
+
it "serialises the ArrayLike without wrapping an array around it" do
|
95
|
+
expect(subject.to_json).to eq expected_json
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
85
99
|
context "when the query contains a Pact::Term" do
|
86
100
|
let(:term) { Pact::Term.new(generate: "thing", matcher: /th/) }
|
87
101
|
let(:query) { { param: term } }
|
@@ -7,10 +7,16 @@ module Pact
|
|
7
7
|
subject { Merge.(expected, matching_rules, "$.body") }
|
8
8
|
|
9
9
|
before do
|
10
|
-
allow($stderr).to receive(:puts)
|
10
|
+
allow($stderr).to receive(:puts) do | message |
|
11
|
+
raise "Was not expecting stderr to receive #{message.inspect} in this spec. This may be because of a missed call to log_used_rule in Merge."
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
15
|
describe "no recognised rules" do
|
16
|
+
before do
|
17
|
+
allow($stderr).to receive(:puts)
|
18
|
+
end
|
19
|
+
|
14
20
|
let(:expected) do
|
15
21
|
{
|
16
22
|
"_links" => {
|
@@ -63,6 +69,10 @@ module Pact
|
|
63
69
|
end
|
64
70
|
|
65
71
|
describe "type based matching" do
|
72
|
+
before do
|
73
|
+
allow($stderr).to receive(:puts)
|
74
|
+
end
|
75
|
+
|
66
76
|
let(:expected) do
|
67
77
|
{
|
68
78
|
"name" => "Mary"
|
@@ -89,6 +99,10 @@ module Pact
|
|
89
99
|
describe "regular expressions" do
|
90
100
|
|
91
101
|
describe "in a hash" do
|
102
|
+
before do
|
103
|
+
allow($stderr).to receive(:puts)
|
104
|
+
end
|
105
|
+
|
92
106
|
let(:expected) do
|
93
107
|
{
|
94
108
|
"_links" => {
|
@@ -178,6 +192,7 @@ module Pact
|
|
178
192
|
"$.body.alligators[*].*" => { 'match' => 'type'}
|
179
193
|
}
|
180
194
|
end
|
195
|
+
|
181
196
|
it "creates a Pact::ArrayLike at the appropriate path" do
|
182
197
|
expect(subject["alligators"]).to be_instance_of(Pact::ArrayLike)
|
183
198
|
expect(subject["alligators"].contents).to eq 'name' => 'Mary'
|
@@ -259,6 +274,10 @@ module Pact
|
|
259
274
|
end
|
260
275
|
|
261
276
|
describe "with an example array with more than one item" do
|
277
|
+
before do
|
278
|
+
allow(Pact.configuration.error_stream).to receive(:puts)
|
279
|
+
end
|
280
|
+
|
262
281
|
let(:expected) do
|
263
282
|
{
|
264
283
|
|
@@ -277,13 +296,7 @@ module Pact
|
|
277
296
|
}
|
278
297
|
end
|
279
298
|
|
280
|
-
xit "doesn't warn about the min size being ignored" do
|
281
|
-
expect(Pact.configuration.error_stream).to receive(:puts).once
|
282
|
-
subject
|
283
|
-
end
|
284
|
-
|
285
299
|
it "warns that the other items will be ignored" do
|
286
|
-
allow(Pact.configuration.error_stream).to receive(:puts)
|
287
300
|
expect(Pact.configuration.error_stream).to receive(:puts).with(/WARN: Only the first item/)
|
288
301
|
subject
|
289
302
|
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.3
|
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-
|
15
|
+
date: 2018-07-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|