pact-support 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pact/shared/form_differ.rb +17 -3
- data/lib/pact/support/version.rb +1 -1
- data/spec/lib/pact/shared/form_differ_spec.rb +41 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79273cad2c28a3b3106d718683b4d867c9fb9bbc
|
4
|
+
data.tar.gz: 56a72d14b91e0928a3acf812288e1989d1dff365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6176fa4dd712fa3a6ab93f0d637fc832f723c9abda2e52adb6ccec83c7581f9765ca018a6ad399769eb52373e6d5aba2364b513748b447e0e3e9b3e6b76919fd
|
7
|
+
data.tar.gz: 02d6c75a7db9874b37d88084a37b7ed94fde000eaab6e3af75823c64fc082d5252f5a3da4ad3ed18ff0d93df43f0290d1d4a0ef5377c07270ca69fceb8e37a63
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
git log --pretty=format:' * %h - %s (%an, %ad)'
|
4
4
|
|
5
|
+
### 0.1.2 (22 October 2014)
|
6
|
+
|
7
|
+
* 00280ac - Added logic to match form data when specified as a Hash (bethesque, Wed Oct 22 15:21:39 2014 +1100)
|
8
|
+
|
5
9
|
### 0.1.1 (22 October 2014)
|
6
10
|
|
7
11
|
* ff6a01d - Disallowing unexpected params in the query (bethesque, Wed Oct 22 14:42:41 2014 +1100)
|
@@ -11,9 +11,23 @@ module Pact
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.to_hash form_body
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
if form_body.is_a?(Hash)
|
15
|
+
ensure_values_are_arrays form_body
|
16
|
+
else
|
17
|
+
decode_www_form form_body
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ensure_values_are_arrays hash
|
22
|
+
hash.each_with_object({}) do | (key, value), hash |
|
23
|
+
hash[key.to_s] = [*value]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.decode_www_form string
|
28
|
+
URI.decode_www_form(string).each_with_object({}) do | (key, value), hash |
|
29
|
+
hash[key] ||= []
|
30
|
+
hash[key] << value
|
17
31
|
end
|
18
32
|
end
|
19
33
|
|
data/lib/pact/support/version.rb
CHANGED
@@ -13,8 +13,8 @@ module Pact
|
|
13
13
|
|
14
14
|
let(:difference) do
|
15
15
|
{
|
16
|
-
|
17
|
-
|
16
|
+
'param1' => [Pact::Matchers::Difference.new("foo", "wiffle")],
|
17
|
+
'param2' => [Pact::Matchers::Difference.new("bar", "foobar"), Pact::Matchers::Difference.new("foobar", "bar")]
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
@@ -26,6 +26,45 @@ module Pact
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
context "when the expected is a matching Hash" do
|
30
|
+
let(:expected) do
|
31
|
+
{
|
32
|
+
param1: "wiffle",
|
33
|
+
param2: ["foobar", "bar"]
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns an empty diff" do
|
38
|
+
expect(subject).to be_empty
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when the expected is a matching Hash with a Pact::Term" do
|
43
|
+
let(:expected) do
|
44
|
+
{
|
45
|
+
param1: "wiffle",
|
46
|
+
param2: [Pact::Term.new(generate: 'foobar', matcher: /bar/), "bar"]
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns an empty diff" do
|
51
|
+
expect(subject).to be_empty
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when the expected is a Hash that doesn't match the actual" do
|
56
|
+
let(:expected) do
|
57
|
+
{
|
58
|
+
param1: "woffle",
|
59
|
+
param2: ["foobar", "bar"]
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
it "returns the diff" do
|
64
|
+
expect(subject).to_not be_empty
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
29
68
|
end
|
30
69
|
|
31
70
|
end
|