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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bbba1bbc7c4a2bf0c9bf83c335bca49f3911b33
4
- data.tar.gz: 074b3a5fbf4ea09514e9a58d6af2d42d22739942
3
+ metadata.gz: fc9f8683f2295ada09a03f4726ac8c8532d2def6
4
+ data.tar.gz: c5796a44f6c28c2070cb37e1ae8d6341e2118463
5
5
  SHA512:
6
- metadata.gz: d15ba35784d2b6a93feeae4f77fd43f32ae2b07d3ece6b1b1a0367d9d05702a6a6dca9696e65287ba782c2ccfc495fc7fb3c8e8a34c57f525ddaf0702acdf6b2
7
- data.tar.gz: 58ebf78d2b351442c2d3ac0ce8a2874949939acb51ca94b5aa7f0b261b1674da0ddd73db983e643267e9dd3b8c0117a80277090ac36690ff71ece9fbb694c118
6
+ metadata.gz: fb794ca126e1566123ab1c7333fb32d3e66851aed50b7f2489b6979380baf802e09cda256fa2806ebffeba3a93371e5627029aa6d515c6e4912b125e457758a8
7
+ data.tar.gz: 862c5fc5b00ddc050e22337565acbae72a72bcd9845767dffed811aca2cdbeb79b124d3a681d40ab0b5fdf6cdec6705970694c6794aac6b7189880a2bef2ac61
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ <a name="v1.7.1"></a>
2
+ ### v1.7.1 (2018-08-09)
3
+
4
+
5
+ #### Bug Fixes
6
+
7
+ * remove incorrect warning messages about matching rules being ignored ([30328e0](/../../commit/30328e0))
8
+
9
+
1
10
  <a name="v1.7.0"></a>
2
11
  ### v1.7.0 (2018-08-07)
3
12
 
@@ -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(wrap(v, new_path), new_path)
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(wrap(item, new_path), new_path)
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
- rules = @matching_rules[path]
81
- array_rules = @matching_rules["#{path}[*]*"]
82
- return object unless rules || array_rules
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, rules
91
+ def handle_match_type object, path
94
92
  log_used_rule(path, 'match', 'type')
95
- Pact::SomethingLike.new(recurse(object, path))
93
+ Pact::SomethingLike.new(object)
96
94
  end
97
95
 
98
- def handle_regex object, path, rules
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', rules['regex'])
101
- Pact::Term.new(generate: object, matcher: Regexp.new(rules['regex']))
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
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "1.7.0"
3
+ VERSION = "1.7.1"
4
4
  end
5
5
  end
@@ -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.0
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-06 00:00:00.000000000 Z
15
+ date: 2018-08-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp