pact-support 1.4.0 → 1.7.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +115 -0
  3. data/lib/pact/configuration.rb +4 -0
  4. data/lib/pact/consumer_contract/consumer_contract.rb +19 -8
  5. data/lib/pact/consumer_contract/http_consumer_contract_parser.rb +37 -0
  6. data/lib/pact/consumer_contract/interaction.rb +52 -57
  7. data/lib/pact/consumer_contract/interaction_parser.rb +23 -0
  8. data/lib/pact/consumer_contract/interaction_v2_parser.rb +28 -0
  9. data/lib/pact/consumer_contract/interaction_v3_parser.rb +61 -0
  10. data/lib/pact/consumer_contract/pact_file.rb +24 -24
  11. data/lib/pact/consumer_contract/query_hash.rb +2 -0
  12. data/lib/pact/consumer_contract/query_string.rb +2 -2
  13. data/lib/pact/consumer_contract/request.rb +1 -5
  14. data/lib/pact/consumer_contract/string_with_matching_rules.rb +17 -0
  15. data/lib/pact/matchers/multipart_form_diff_formatter.rb +41 -0
  16. data/lib/pact/matching_rules/merge.rb +30 -14
  17. data/lib/pact/matching_rules/v3/extract.rb +94 -0
  18. data/lib/pact/matching_rules/v3/merge.rb +128 -0
  19. data/lib/pact/matching_rules.rb +19 -6
  20. data/lib/pact/reification.rb +6 -3
  21. data/lib/pact/shared/multipart_form_differ.rb +14 -0
  22. data/lib/pact/specification_version.rb +18 -0
  23. data/lib/pact/support/version.rb +1 -1
  24. data/script/release.sh +1 -1
  25. data/spec/fixtures/multipart-form-diff.txt +9 -0
  26. data/spec/fixtures/not-a-pact.json +3 -0
  27. data/spec/fixtures/pact-http-v2.json +36 -0
  28. data/spec/fixtures/pact-http-v3.json +36 -0
  29. data/spec/integration/matching_rules_extract_and_merge_spec.rb +41 -4
  30. data/spec/lib/pact/consumer_contract/consumer_contract_spec.rb +54 -31
  31. data/spec/lib/pact/consumer_contract/http_consumer_contract_parser_spec.rb +25 -0
  32. data/spec/lib/pact/consumer_contract/interaction_parser_spec.rb +62 -0
  33. data/spec/lib/pact/consumer_contract/interaction_spec.rb +0 -23
  34. data/spec/lib/pact/consumer_contract/pact_file_spec.rb +9 -0
  35. data/spec/lib/pact/consumer_contract/query_hash_spec.rb +23 -0
  36. data/spec/lib/pact/matchers/multipart_form_diff_formatter_spec.rb +36 -0
  37. data/spec/lib/pact/matching_rules/merge_spec.rb +20 -7
  38. data/spec/lib/pact/matching_rules/v3/extract_spec.rb +238 -0
  39. data/spec/lib/pact/matching_rules/v3/merge_spec.rb +386 -0
  40. data/spec/lib/pact/matching_rules_spec.rb +82 -0
  41. data/spec/lib/pact/reification_spec.rb +18 -5
  42. data/spec/lib/pact/shared/multipart_form_differ_spec.rb +39 -0
  43. data/tasks/spec.rake +0 -1
  44. metadata +35 -3
@@ -0,0 +1,41 @@
1
+ require 'pact/matchers/unix_diff_formatter'
2
+ require 'pact/matchers/differ'
3
+
4
+ module Pact
5
+ module Matchers
6
+ class MultipartFormDiffFormatter
7
+
8
+ def initialize diff, options = {}
9
+ @options = options
10
+ @body_diff = diff[:body]
11
+ @non_body_diff = diff.reject{ |k, v| k == :body }
12
+ @colour = options.fetch(:colour, false)
13
+ @differ = Pact::Matchers::Differ.new(@colour)
14
+ end
15
+
16
+ def self.call diff, options = {}
17
+ new(diff, options).call
18
+ end
19
+
20
+ def call
21
+ Pact::Matchers::UnixDiffFormatter::MESSAGES_TITLE + "\n" + non_body_diff_string + "\n" + body_diff_string
22
+ end
23
+
24
+ def non_body_diff_string
25
+ if @non_body_diff.any?
26
+ Pact::Matchers::ExtractDiffMessages.call(@non_body_diff).collect{ | message| "* #{message}" }.join("\n")
27
+ else
28
+ ""
29
+ end
30
+ end
31
+
32
+ def body_diff_string
33
+ if @body_diff
34
+ @differ.diff_as_string(@body_diff.expected, @body_diff.actual)
35
+ else
36
+ ""
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -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 @expected, @root_path
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
- 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']
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
- log_ignored_rules(path, rules, {'match' => 'type'})
91
- Pact::SomethingLike.new(object)
94
+ log_used_rule(path, 'match', 'type')
95
+ Pact::SomethingLike.new(recurse(object, path))
92
96
  end
93
97
 
94
98
  def handle_regex object, path, rules
95
- log_ignored_rules(path, rules, {'match' => 'regex', 'regex' => rules['regex']})
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 path, rules, used_rules
100
- dup_rules = rules.dup
101
- used_rules.each_pair do | used_key, used_value |
102
- dup_rules.delete(used_key) if dup_rules[used_key] == used_value
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
- $stderr.puts "WARN: Ignoring unsupported matching rules #{dup_rules} for path #{path}"
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
@@ -0,0 +1,94 @@
1
+ require 'pact/something_like'
2
+ require 'pact/array_like'
3
+ require 'pact/term'
4
+
5
+ module Pact
6
+ module MatchingRules::V3
7
+ class Extract
8
+
9
+ def self.call matchable
10
+ new(matchable).call
11
+ end
12
+
13
+ def initialize matchable
14
+ @matchable = matchable
15
+ @rules = Hash.new
16
+ end
17
+
18
+ def call
19
+ recurse matchable, "$", nil
20
+ rules
21
+ end
22
+
23
+ private
24
+
25
+ attr_reader :matchable, :rules
26
+
27
+ def recurse object, path, match_type
28
+ case object
29
+ when Hash then recurse_hash(object, path, match_type)
30
+ when Array then recurse_array(object, path, match_type)
31
+ when Pact::SomethingLike then handle_something_like(object, path, match_type)
32
+ when Pact::ArrayLike then handle_array_like(object, path, match_type)
33
+ when Pact::Term then record_regex_rule object, path
34
+ when Pact::QueryString then recurse(object.query, path, match_type)
35
+ when Pact::QueryHash then recurse_hash(object.query, path, match_type)
36
+ end
37
+ end
38
+
39
+ def recurse_hash hash, path, match_type
40
+ hash.each do | (key, value) |
41
+ recurse value, "#{path}#{next_path_part(key)}", match_type
42
+ end
43
+ end
44
+
45
+ def recurse_array new_array, path, match_type
46
+ new_array.each_with_index do | value, index |
47
+ recurse value, "#{path}[#{index}]", match_type
48
+ end
49
+ end
50
+
51
+ def handle_something_like something_like, path, match_type
52
+ record_match_type_rule path, "type"
53
+ recurse something_like.contents, path, "type"
54
+ end
55
+
56
+ def handle_array_like array_like, path, match_type
57
+ record_rule "#{path}", 'min' => array_like.min
58
+ record_match_type_rule "#{path}[*].*", 'type'
59
+ recurse array_like.contents, "#{path}[*]", :array_like
60
+ end
61
+
62
+ def record_rule path, rule
63
+ rules[path] ||= {}
64
+ rules[path]['matchers'] ||= []
65
+ rules[path]['matchers'] << rule
66
+ end
67
+
68
+ def record_regex_rule term, path
69
+ rules[path] ||= {}
70
+ rules[path]['matchers'] ||= []
71
+ rule = { 'match' => 'regex', 'regex' => term.matcher.inspect[1..-2]}
72
+ rules[path]['matchers'] << rule
73
+ end
74
+
75
+ def record_match_type_rule path, match_type
76
+ unless match_type == :array_like || match_type.nil?
77
+ rules[path] ||= {}
78
+ rules[path]['matchers'] ||= []
79
+ rules[path]['matchers'] << { 'match' => match_type }
80
+ end
81
+ end
82
+
83
+ # Beth: there's a potential bug if the key contains a dot and a single quote.
84
+ # Not sure what to do then.
85
+ def next_path_part key
86
+ if key.to_s.include?('.')
87
+ "['#{key}']"
88
+ else
89
+ ".#{key}"
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,128 @@
1
+ require 'pact/array_like'
2
+ require 'pact/matching_rules/jsonpath'
3
+
4
+ module Pact
5
+ module MatchingRules
6
+ module V3
7
+ class Merge
8
+
9
+ def self.call expected, matching_rules, root_path = '$'
10
+ new(expected, matching_rules, root_path).call
11
+ end
12
+
13
+ def initialize expected, matching_rules, root_path
14
+ @expected = expected
15
+ @matching_rules = standardise_paths(matching_rules)
16
+ @root_path = JsonPath.new(root_path).to_s
17
+ end
18
+
19
+ def call
20
+ return @expected if @matching_rules.nil? || @matching_rules.empty?
21
+ recurse(@expected, @root_path).tap { log_ignored_rules }
22
+ end
23
+
24
+ private
25
+
26
+ def standardise_paths matching_rules
27
+ return matching_rules if matching_rules.nil? || matching_rules.empty?
28
+ matching_rules.each_with_object({}) do | (path, rules), new_matching_rules |
29
+ new_matching_rules[JsonPath.new(path).to_s] = Marshal.load(Marshal.dump(rules)) # simplest way to deep clone
30
+ end
31
+ end
32
+
33
+ def recurse expected, path
34
+ case expected
35
+ when Hash then recurse_hash(expected, path)
36
+ when Array then recurse_array(expected, path)
37
+ else
38
+ expected
39
+ end
40
+ end
41
+
42
+ def recurse_hash hash, path
43
+ hash.each_with_object({}) do | (k, v), new_hash |
44
+ new_path = path + "['#{k}']"
45
+ new_hash[k] = recurse(wrap(v, new_path), new_path)
46
+ end
47
+ end
48
+
49
+ def recurse_array array, path
50
+
51
+ parent_match_rule = @matching_rules[path] && @matching_rules[path]['matchers'] && @matching_rules[path]['matchers'].first && @matching_rules[path]['matchers'].first.delete('match')
52
+ array_like_children_path = "#{path}[*]*"
53
+ children_match_rule = @matching_rules[array_like_children_path] && @matching_rules[array_like_children_path]['matchers'] && @matching_rules[array_like_children_path]['matchers'].first && @matching_rules[array_like_children_path]['matchers'].first.delete('match')
54
+ min = @matching_rules[path] && @matching_rules[path]['matchers'] && @matching_rules[path]['matchers'].first && @matching_rules[path]['matchers'].first.delete('min')
55
+
56
+ if min && (children_match_rule == 'type' || (children_match_rule.nil? && parent_match_rule == 'type'))
57
+ warn_when_not_one_example_item(array, path)
58
+ Pact::ArrayLike.new(recurse(array.first, "#{path}[*]"), min: min)
59
+ else
60
+ new_array = []
61
+ array.each_with_index do | item, index |
62
+ new_path = path + "[#{index}]"
63
+ new_array << recurse(wrap(item, new_path), new_path)
64
+ end
65
+ new_array
66
+ end
67
+ end
68
+
69
+ def warn_when_not_one_example_item array, path
70
+ unless array.size == 1
71
+ Pact.configuration.error_stream.puts "WARN: Only the first item will be used to match the items in the array at #{path}"
72
+ end
73
+ end
74
+
75
+ def wrap object, path
76
+ rules = @matching_rules[path] && @matching_rules[path]['matchers'] && @matching_rules[path]['matchers'].first
77
+ array_rules = @matching_rules["#{path}[*]*"] && @matching_rules["#{path}[*]*"]['matchers'] && @matching_rules["#{path}[*]*"]['matchers'].first
78
+ return object unless rules || array_rules
79
+
80
+ if rules['match'] == 'type' && !rules.has_key?('min')
81
+ handle_match_type(object, path, rules)
82
+ elsif rules['regex']
83
+ handle_regex(object, path, rules)
84
+ else
85
+ #log_ignored_rules(path, rules, {})
86
+ object
87
+ end
88
+ end
89
+
90
+ def handle_match_type object, path, rules
91
+ rules.delete('match')
92
+ Pact::SomethingLike.new(recurse(object, path))
93
+ end
94
+
95
+ def handle_regex object, path, rules
96
+ rules.delete('match')
97
+ regex = rules.delete('regex')
98
+ Pact::Term.new(generate: object, matcher: Regexp.new(regex))
99
+ end
100
+
101
+ def log_ignored_rules
102
+ @matching_rules.each do | jsonpath, rules_hash |
103
+ rules_array = rules_hash["matchers"]
104
+ ((rules_array.length - 1)..0).each do | index |
105
+ rules_array.delete_at(index) if rules_array[index].empty?
106
+ end
107
+ end
108
+
109
+ if @matching_rules.any?
110
+ @matching_rules.each do | path, rules_hash |
111
+ rules_hash.each do | key, value |
112
+ $stderr.puts "WARN: Ignoring unsupported #{key} #{value} for path #{path}" if value.any?
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ def find_rule(path, key)
119
+ @matching_rules[path] && @matching_rules[path][key]
120
+ end
121
+
122
+ def log_used_rule path, key, value
123
+ @used_rules << [path, key, value]
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
@@ -1,17 +1,30 @@
1
1
  require 'pact/matching_rules/extract'
2
+ require 'pact/matching_rules/v3/extract'
2
3
  require 'pact/matching_rules/merge'
4
+ require 'pact/matching_rules/v3/merge'
3
5
 
4
6
  module Pact
5
7
  module MatchingRules
6
8
 
7
9
  # @api public Used by pact-mock_service
8
- def self.extract object_graph
9
- Extract.(object_graph)
10
+ def self.extract object_graph, options = {}
11
+ pact_specification_version = options[:pact_specification_version] || Pact::SpecificationVersion::NIL_VERSION
12
+ case pact_specification_version.major
13
+ when nil, 0, 1, 2
14
+ Extract.(object_graph)
15
+ else
16
+ V3::Extract.(object_graph)
17
+ end
10
18
  end
11
19
 
12
- def self.merge object_graph, matching_rules
13
- Merge.(object_graph, matching_rules)
20
+ def self.merge object_graph, matching_rules, options = {}
21
+ pact_specification_version = options[:pact_specification_version] || Pact::SpecificationVersion::NIL_VERSION
22
+ case pact_specification_version.major
23
+ when nil, 0, 1, 2
24
+ Merge.(object_graph, matching_rules)
25
+ else
26
+ V3::Merge.(object_graph, matching_rules)
27
+ end
14
28
  end
15
-
16
29
  end
17
- end
30
+ end
@@ -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
@@ -26,15 +27,17 @@ module Pact
26
27
  when Pact::QueryString
27
28
  from_term(term.query)
28
29
  when Pact::QueryHash
29
- term.query.map { |k, v|
30
+ from_term(term.query).map { |k, v|
30
31
  if v.nil?
31
32
  k
32
33
  elsif v.is_a?(Array) #For cases where there are multiple instance of the same parameter
33
- v.map { |x| "#{k}=#{escape(from_term(x))}"}.join('&')
34
+ v.map { |x| "#{k}=#{escape(x)}"}.join('&')
34
35
  else
35
- "#{k}=#{escape(from_term(v))}"
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
@@ -0,0 +1,14 @@
1
+ require 'uri'
2
+ require 'pact/shared/text_differ'
3
+
4
+ module Pact
5
+ class MultipartFormDiffer
6
+ def self.call expected, actual, options = {}
7
+ require 'pact/matchers' # avoid recursive loop between this file and pact/matchers
8
+ expected_boundary = expected.split.first
9
+ actual_boundary = actual.split.first
10
+ actual_with_hardcoded_boundary = actual.gsub(actual_boundary, expected_boundary)
11
+ TextDiffer.call(expected, actual_with_hardcoded_boundary, options)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ module Pact
2
+ class SpecificationVersion < Gem::Version
3
+
4
+ def major
5
+ segments.first
6
+ end
7
+
8
+ def === other
9
+ major && major == other
10
+ end
11
+
12
+ def after? other
13
+ major && other < major
14
+ end
15
+ end
16
+
17
+ SpecificationVersion::NIL_VERSION = Pact::SpecificationVersion.new('0')
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "1.4.0"
3
+ VERSION = "1.7.0"
4
4
  end
5
5
  end
data/script/release.sh CHANGED
@@ -5,5 +5,5 @@ git checkout -- lib/pact/support/version.rb
5
5
  bundle exec bump ${1:-minor} --no-commit
6
6
  bundle exec rake generate_changelog
7
7
  git add CHANGELOG.md lib/pact/support/version.rb
8
- git commit -m "Releasing version $(ruby -r ./lib/pact/support/version.rb -e "puts Pact::Support::VERSION")"
8
+ git commit -m "chore(release): version $(ruby -r ./lib/pact/support/version.rb -e "puts Pact::Support::VERSION")"
9
9
  bundle exec rake release
@@ -0,0 +1,9 @@
1
+
2
+
3
+ Description of differences
4
+ --------------------------------------
5
+ * Wrong header
6
+
7
+ @@ -1,2 +1,2 @@
8
+ -bar
9
+ +foo
@@ -0,0 +1,3 @@
1
+ {
2
+ "foo": "bar"
3
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "consumer": {
3
+ "name": "some-test-consumer"
4
+ },
5
+ "provider": {
6
+ "name": "an unknown provider"
7
+ },
8
+ "interactions": [
9
+ {
10
+ "description": "a test request",
11
+ "request": {
12
+ "method": "get",
13
+ "path": "/weather",
14
+ "query": ""
15
+ },
16
+ "response": {
17
+ "matchingRules": {
18
+ "$.headers.Content-Type" : {
19
+ "match": "regex", "regex": "json"
20
+ },
21
+ "$.body.message" : {
22
+ "match": "regex", "regex": "sun"
23
+ }
24
+ },
25
+ "status": 200,
26
+ "headers" : {
27
+ "Content-Type": "foo/json"
28
+ },
29
+ "body": {
30
+ "message" : "sunful"
31
+ }
32
+ },
33
+ "provider_state": "the weather is sunny"
34
+ }
35
+ ]
36
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "consumer": {
3
+ "name": "consumer"
4
+ },
5
+ "interactions": [
6
+ {
7
+ "description": "a test request",
8
+ "providerState": "the weather is sunny",
9
+ "request": {
10
+ "method": "get",
11
+ "path": "/foo"
12
+ },
13
+ "response": {
14
+ "body": {
15
+ "foo": "bar"
16
+ },
17
+ "matchingRules": {
18
+ "body": {
19
+ "$.foo": {
20
+ "matchers": [{ "match": "type" }]
21
+ }
22
+ }
23
+ },
24
+ "status": 200
25
+ }
26
+ }
27
+ ],
28
+ "provider": {
29
+ "name": "provider"
30
+ },
31
+ "metadata": {
32
+ "pactSpecification": {
33
+ "version": "3.0"
34
+ }
35
+ }
36
+ }
@@ -1,7 +1,9 @@
1
1
  require 'pact/term'
2
2
  require 'pact/something_like'
3
3
  require 'pact/matching_rules/extract'
4
+ require 'pact/matching_rules/v3/extract'
4
5
  require 'pact/matching_rules/merge'
6
+ require 'pact/matching_rules/v3/merge'
5
7
  require 'pact/reification'
6
8
 
7
9
  describe "converting Pact::Term and Pact::SomethingLike to matching rules and back again" do
@@ -10,6 +12,9 @@ describe "converting Pact::Term and Pact::SomethingLike to matching rules and ba
10
12
  let(:matching_rules) { Pact::MatchingRules::Extract.(expected) }
11
13
  let(:recreated_expected) { Pact::MatchingRules::Merge.(example, matching_rules)}
12
14
 
15
+ let(:recreated_expected_v3) { Pact::MatchingRules::V3::Merge.(example, matching_rules_v3) }
16
+ let(:matching_rules_v3) { Pact::MatchingRules::V3::Extract.(expected) }
17
+
13
18
  context "with a Pact::Term" do
14
19
  let(:expected) do
15
20
  {
@@ -21,9 +26,29 @@ describe "converting Pact::Term and Pact::SomethingLike to matching rules and ba
21
26
  }
22
27
  end
23
28
 
24
- it "recreates the same object hierarchy" do
29
+ it "recreates the same object hierarchy with v2 matching" do
30
+ expect(recreated_expected).to eq expected
31
+ end
32
+
33
+ it "recreates the same object hierarchy with v3 matching" do
34
+ expect(recreated_expected_v3).to eq expected
35
+ end
36
+ end
37
+
38
+ context "with a Pact::SomethingLike containing a Pact::ArrayLike" do
39
+ let(:expected) do
40
+ {
41
+ body: Pact::SomethingLike.new(children: Pact::ArrayLike.new("foo", min: 2))
42
+ }
43
+ end
44
+
45
+ it "recreates the same object hierarchy with v2 matching" do
25
46
  expect(recreated_expected).to eq expected
26
47
  end
48
+
49
+ it "recreates the same object hierarchy with v3 matching" do
50
+ expect(recreated_expected_v3).to eq expected
51
+ end
27
52
  end
28
53
 
29
54
  context "with a Pact::SomethingLike" do
@@ -37,9 +62,13 @@ describe "converting Pact::Term and Pact::SomethingLike to matching rules and ba
37
62
  }
38
63
  end
39
64
 
40
- it "recreates the same object hierarchy" do
65
+ it "recreates the same object hierarchy with v2 matching" do
41
66
  expect(recreated_expected).to eq expected
42
67
  end
68
+
69
+ it "recreates the same object hierarchy with v3 matching" do
70
+ expect(recreated_expected_v3).to eq expected
71
+ end
43
72
  end
44
73
 
45
74
  context "with a Pact::SomethingLike containing a Hash" do
@@ -61,9 +90,13 @@ describe "converting Pact::Term and Pact::SomethingLike to matching rules and ba
61
90
  }
62
91
  end
63
92
 
64
- it "recreates the same object hierarchy" do
93
+ it "recreates the same object hierarchy with v2 matching" do
65
94
  expect(recreated_expected).to eq expected
66
95
  end
96
+
97
+ it "recreates the same object hierarchy with v3 matching" do
98
+ expect(recreated_expected_v3).to eq expected
99
+ end
67
100
  end
68
101
 
69
102
  context "with a Pact::SomethingLike containing an Array" do
@@ -83,8 +116,12 @@ describe "converting Pact::Term and Pact::SomethingLike to matching rules and ba
83
116
  }
84
117
  end
85
118
 
86
- it "recreates the same object hierarchy" do
119
+ it "recreates the same object hierarchy with v2 matching" do
87
120
  expect(recreated_expected).to eq expected
88
121
  end
122
+
123
+ it "recreates the same object hierarchy with v3 matching" do
124
+ expect(recreated_expected_v3).to eq expected
125
+ end
89
126
  end
90
127
  end