pact-support 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/pact/matching_rules/merge.rb +16 -17
- data/lib/pact/support/version.rb +1 -1
- data/spec/lib/pact/matching_rules/merge_spec.rb +57 -2
- 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: fc9f8683f2295ada09a03f4726ac8c8532d2def6
|
4
|
+
data.tar.gz: c5796a44f6c28c2070cb37e1ae8d6341e2118463
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb794ca126e1566123ab1c7333fb32d3e66851aed50b7f2489b6979380baf802e09cda256fa2806ebffeba3a93371e5627029aa6d515c6e4912b125e457758a8
|
7
|
+
data.tar.gz: 862c5fc5b00ddc050e22337565acbae72a72bcd9845767dffed811aca2cdbeb79b124d3a681d40ab0b5fdf6cdec6705970694c6794aac6b7189880a2bef2ac61
|
data/CHANGELOG.md
CHANGED
@@ -31,18 +31,20 @@ module Pact
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def recurse expected, path
|
34
|
-
case expected
|
34
|
+
recursed = case expected
|
35
35
|
when Hash then recurse_hash(expected, path)
|
36
36
|
when Array then recurse_array(expected, path)
|
37
37
|
else
|
38
38
|
expected
|
39
39
|
end
|
40
|
+
|
41
|
+
wrap(recursed, path)
|
40
42
|
end
|
41
43
|
|
42
44
|
def recurse_hash hash, path
|
43
|
-
hash.each_with_object({}) do | (k, v), new_hash |
|
45
|
+
recursed = hash.each_with_object({}) do | (k, v), new_hash |
|
44
46
|
new_path = path + "['#{k}']"
|
45
|
-
new_hash[k] = recurse(
|
47
|
+
new_hash[k] = recurse(v, new_path)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -64,7 +66,7 @@ module Pact
|
|
64
66
|
new_array = []
|
65
67
|
array.each_with_index do | item, index |
|
66
68
|
new_path = path + "[#{index}]"
|
67
|
-
new_array << recurse(
|
69
|
+
new_array << recurse(item, new_path)
|
68
70
|
end
|
69
71
|
new_array
|
70
72
|
end
|
@@ -77,28 +79,25 @@ module Pact
|
|
77
79
|
end
|
78
80
|
|
79
81
|
def wrap object, path
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
if rules['match'] == 'type' && !rules.has_key?('min')
|
85
|
-
handle_match_type(object, path, rules)
|
86
|
-
elsif rules['regex']
|
87
|
-
handle_regex(object, path, rules)
|
82
|
+
if find_rule(path, 'match') == 'type' && !find_rule(path, 'min')
|
83
|
+
handle_match_type(object, path)
|
84
|
+
elsif find_rule(path, 'regex')
|
85
|
+
handle_regex(object, path)
|
88
86
|
else
|
89
87
|
object
|
90
88
|
end
|
91
89
|
end
|
92
90
|
|
93
|
-
def handle_match_type object, path
|
91
|
+
def handle_match_type object, path
|
94
92
|
log_used_rule(path, 'match', 'type')
|
95
|
-
Pact::SomethingLike.new(
|
93
|
+
Pact::SomethingLike.new(object)
|
96
94
|
end
|
97
95
|
|
98
|
-
def handle_regex object, path
|
96
|
+
def handle_regex object, path
|
97
|
+
regex = find_rule(path, 'regex')
|
99
98
|
log_used_rule(path, 'match', 'regex') # assumed to be present
|
100
|
-
log_used_rule(path, 'regex',
|
101
|
-
Pact::Term.new(generate: object, matcher: Regexp.new(
|
99
|
+
log_used_rule(path, 'regex', regex)
|
100
|
+
Pact::Term.new(generate: object, matcher: Regexp.new(regex))
|
102
101
|
end
|
103
102
|
|
104
103
|
def log_ignored_rules
|
data/lib/pact/support/version.rb
CHANGED
@@ -70,7 +70,7 @@ module Pact
|
|
70
70
|
|
71
71
|
describe "type based matching" do
|
72
72
|
before do
|
73
|
-
allow($stderr).to receive(:puts)
|
73
|
+
allow($stderr).to receive(:puts).and_call_original
|
74
74
|
end
|
75
75
|
|
76
76
|
let(:expected) do
|
@@ -90,7 +90,7 @@ module Pact
|
|
90
90
|
end
|
91
91
|
|
92
92
|
it "it logs the rules it has ignored" do
|
93
|
-
expect($stderr).to receive(:puts).with(/ignored.*matchingrule/)
|
93
|
+
expect($stderr).to receive(:puts).once.with(/ignored.*matchingrule/)
|
94
94
|
subject
|
95
95
|
end
|
96
96
|
|
@@ -356,6 +356,61 @@ module Pact
|
|
356
356
|
expect(subject['@name']).to be_instance_of(Pact::SomethingLike)
|
357
357
|
end
|
358
358
|
end
|
359
|
+
|
360
|
+
describe "when a Pact.like is nested inside a Pact.each_like which is nested inside a Pact.like" do
|
361
|
+
let(:original_definition) do
|
362
|
+
Pact.like('foos' => Pact.each_like(Pact.like('name' => "foo1")))
|
363
|
+
end
|
364
|
+
|
365
|
+
let(:expected) do
|
366
|
+
Pact::Reification.from_term(original_definition)
|
367
|
+
end
|
368
|
+
|
369
|
+
let(:matching_rules) do
|
370
|
+
Extract.call(body: original_definition)
|
371
|
+
end
|
372
|
+
|
373
|
+
it "creates a Pact::SomethingLike containing a Pact::ArrayLike containing a Pact::SomethingLike" do
|
374
|
+
expect(subject.to_hash).to eq original_definition.to_hash
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
describe "when a Pact.array_like is the top level object" do
|
379
|
+
let(:original_definition) do
|
380
|
+
Pact.each_like('foos')
|
381
|
+
end
|
382
|
+
|
383
|
+
let(:expected) do
|
384
|
+
Pact::Reification.from_term(original_definition)
|
385
|
+
end
|
386
|
+
|
387
|
+
let(:matching_rules) do
|
388
|
+
Extract.call(body: original_definition)
|
389
|
+
end
|
390
|
+
|
391
|
+
it "creates a Pact::ArrayLike" do
|
392
|
+
expect(subject.to_hash).to eq original_definition.to_hash
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
describe "when a Pact.like containing an array is the top level object" do
|
397
|
+
let(:original_definition) do
|
398
|
+
Pact.like(['foos'])
|
399
|
+
end
|
400
|
+
|
401
|
+
let(:expected) do
|
402
|
+
Pact::Reification.from_term(original_definition)
|
403
|
+
end
|
404
|
+
|
405
|
+
let(:matching_rules) do
|
406
|
+
Extract.call(body: original_definition)
|
407
|
+
end
|
408
|
+
|
409
|
+
it "creates a Pact::SomethingLike" do
|
410
|
+
expect(subject).to be_a(Pact::SomethingLike)
|
411
|
+
expect(subject.to_hash).to eq original_definition.to_hash
|
412
|
+
end
|
413
|
+
end
|
359
414
|
end
|
360
415
|
end
|
361
416
|
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.7.
|
4
|
+
version: 1.7.1
|
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-08-
|
15
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: randexp
|