pact-support 1.16.6 → 1.16.7

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
  SHA256:
3
- metadata.gz: 87344137693fa6e4f3a31d9794ab10a09680cebc96d5caaa62b9191b54643347
4
- data.tar.gz: 4ee4e677c7d144e5fef6bf93ee568ee9a8f588bd04ba6b13b0c45bc7ddb044b8
3
+ metadata.gz: 6b1de8b63cb135275a86faed84d5d19801511635776af1df35a3623404ada402
4
+ data.tar.gz: e0b91f3241c8182a388cf797243386e8880378e52dd4d92ae4c65d933e17b1b5
5
5
  SHA512:
6
- metadata.gz: a7d9067f4a4582fc58ed8e74abc6201ec21060701f9baf7e40fcbc4887982aafef05afa1a11534bca492e57253ee37f91a764dd03c81abaa4d62cb90976f178a
7
- data.tar.gz: 607223093f8ec2b7adb4415d229cfa2a0ed2fa2a74e633ed444d61ac2b9775b7097ea11d8b1dc70873b33249cb44c8f7f86ab42c9bbe1369367b99da7cddc77f
6
+ metadata.gz: 27276869572d6aec5d75a761b29ac5689ebf52bcfca16741fae40ba0430466cecba0f3281d1f537aad09026c6f60af6289772e143f1581a73b45b47c8492e1b1
7
+ data.tar.gz: 87be707868c70b0dc2136e476721e8ccd575529a48d5e4092bf55886a18c7bc2d424036d86e50c317b5ccb2b591bbcd9d8394cd4dc0da1844ce2069a5d8c379f
@@ -1,3 +1,10 @@
1
+ <a name="v1.16.7"></a>
2
+ ### v1.16.7 (2021-01-28)
3
+
4
+ #### Bug Fixes
5
+
6
+ * dynamically parse actual query to match expected format ([a86a3e3](/../../commit/a86a3e3))
7
+
1
8
  <a name="v1.16.6"></a>
2
9
  ### v1.16.6 (2021-01-28)
3
10
 
@@ -36,7 +36,7 @@ module Pact
36
36
  # in the translation between string => structured object, as we don't know/store which
37
37
  # query string convention was used.
38
38
  if query_is_string
39
- request_hash['query'] = Pact::QueryHash.new(request_hash['query'], original_query_string)
39
+ request_hash['query'] = Pact::QueryHash.new(request_hash['query'], original_query_string, Pact::Query.parsed_as_nested?(request_hash['query']))
40
40
  end
41
41
  request = Pact::Request::Expected.from_hash(request_hash)
42
42
  end
@@ -6,6 +6,8 @@ module Pact
6
6
  DEFAULT_SEP = /[&;] */n
7
7
  COMMON_SEP = { ";" => /[;] */n, ";," => /[;,] */n, "&" => /[&] */n }
8
8
 
9
+ class NestedQuery < Hash; end
10
+
9
11
  def self.create query
10
12
  if query.is_a? Hash
11
13
  Pact::QueryHash.new(query)
@@ -18,12 +20,16 @@ module Pact
18
20
  object.is_a?(Pact::QueryHash) || object.is_a?(Pact::QueryString)
19
21
  end
20
22
 
23
+ def self.parsed_as_nested?(object)
24
+ object.is_a?(NestedQuery)
25
+ end
26
+
21
27
  def self.parse_string query_string
22
- parsed_query = parse_query(query_string)
28
+ parsed_query = parse_string_as_non_nested_query(query_string)
23
29
 
24
30
  # If Rails nested params...
25
31
  if parsed_query.keys.any?{ | key| key =~ /\[.*\]/ }
26
- parse_nested_query(query_string)
32
+ parse_string_as_nested_query(query_string)
27
33
  else
28
34
  parsed_query.each_with_object({}) do | (key, value), new_hash |
29
35
  new_hash[key] = [*value]
@@ -33,7 +39,7 @@ module Pact
33
39
 
34
40
  # Ripped from Rack to avoid adding an unnecessary dependency, thank you Rack
35
41
  # https://github.com/rack/rack/blob/649c72bab9e7b50d657b5b432d0c205c95c2be07/lib/rack/utils.rb
36
- def self.parse_query(qs, d = nil, &unescaper)
42
+ def self.parse_string_as_non_nested_query(qs, d = nil, &unescaper)
37
43
  unescaper ||= method(:unescape)
38
44
 
39
45
  params = {}
@@ -56,7 +62,7 @@ module Pact
56
62
  return params.to_h
57
63
  end
58
64
 
59
- def self.parse_nested_query(qs, d = nil)
65
+ def self.parse_string_as_nested_query(qs, d = nil)
60
66
  params = {}
61
67
 
62
68
  unless qs.nil? || qs.empty?
@@ -67,7 +73,7 @@ module Pact
67
73
  end
68
74
  end
69
75
 
70
- return params.to_h
76
+ return NestedQuery[params.to_h]
71
77
  end
72
78
 
73
79
  def self.normalize_params(params, name, v)
@@ -10,9 +10,18 @@ module Pact
10
10
 
11
11
  attr_reader :original_string
12
12
 
13
- def initialize(query, original_string = nil)
13
+ def initialize(query, original_string = nil, nested = false)
14
14
  @hash = query.nil? ? query : convert_to_hash_of_arrays(query)
15
15
  @original_string = original_string
16
+ @nested = nested
17
+ end
18
+
19
+ def nested?
20
+ @nested
21
+ end
22
+
23
+ def any_key_contains_square_brackets?
24
+ query.keys.any?{ |key| key =~ /\[.*\]/ }
16
25
  end
17
26
 
18
27
  def as_json(opts = {})
@@ -35,7 +44,14 @@ module Pact
35
44
  # from the actual query string.
36
45
  def difference(other)
37
46
  require 'pact/matchers' # avoid recursive loop between this file, pact/reification and pact/matchers
38
- Pact::Matchers.diff(query, symbolize_keys(convert_to_hash_of_arrays(Query.parse_string(other.query))), allow_unexpected_keys: false)
47
+
48
+ if any_key_contains_square_brackets?
49
+ other_query_hash_non_nested = Query.parse_string_as_non_nested_query(other.query)
50
+ Pact::Matchers.diff(query, convert_to_hash_of_arrays(other_query_hash_non_nested), allow_unexpected_keys: false)
51
+ else
52
+ other_query_hash = Query.parse_string(other.query)
53
+ Pact::Matchers.diff(query, symbolize_keys(convert_to_hash_of_arrays(other_query_hash)), allow_unexpected_keys: false)
54
+ end
39
55
  end
40
56
 
41
57
  def query
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "1.16.6"
3
+ VERSION = "1.16.7"
4
4
  end
5
5
  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.16.6
4
+ version: 1.16.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser