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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b1de8b63cb135275a86faed84d5d19801511635776af1df35a3623404ada402
|
4
|
+
data.tar.gz: e0b91f3241c8182a388cf797243386e8880378e52dd4d92ae4c65d933e17b1b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27276869572d6aec5d75a761b29ac5689ebf52bcfca16741fae40ba0430466cecba0f3281d1f537aad09026c6f60af6289772e143f1581a73b45b47c8492e1b1
|
7
|
+
data.tar.gz: 87be707868c70b0dc2136e476721e8ccd575529a48d5e4092bf55886a18c7bc2d424036d86e50c317b5ccb2b591bbcd9d8394cd4dc0da1844ce2069a5d8c379f
|
data/CHANGELOG.md
CHANGED
@@ -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 =
|
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
|
-
|
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.
|
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.
|
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
|
-
|
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
|
data/lib/pact/support/version.rb
CHANGED