pact-support 0.1.1 → 0.1.2

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: df14a80c6fb9e36924a13bdf658aaae7f244183f
4
- data.tar.gz: c84bef17499b45fb3a1ba67fcf4152dc81a2ef63
3
+ metadata.gz: 79273cad2c28a3b3106d718683b4d867c9fb9bbc
4
+ data.tar.gz: 56a72d14b91e0928a3acf812288e1989d1dff365
5
5
  SHA512:
6
- metadata.gz: 2dc586e4103e8596c17e370b8a3c384745c92abfb5a64f39413b5a0a43fce9324ddd1d3591c8bd87d4a6914f67a492c50382aac952180f8bb0d0ba21bdee5972
7
- data.tar.gz: 6acab79c481d452bca05ae0d90a30b353efac77ef529154630bb3779aa3817fa2829be944bbfaf7bc13d0b2ad4f9dbc95d58f3c79934058d66ac30a4285c019f
6
+ metadata.gz: 6176fa4dd712fa3a6ab93f0d637fc832f723c9abda2e52adb6ccec83c7581f9765ca018a6ad399769eb52373e6d5aba2364b513748b447e0e3e9b3e6b76919fd
7
+ data.tar.gz: 02d6c75a7db9874b37d88084a37b7ed94fde000eaab6e3af75823c64fc082d5252f5a3da4ad3ed18ff0d93df43f0290d1d4a0ef5377c07270ca69fceb8e37a63
@@ -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
- URI.decode_www_form(form_body).each_with_object({}) do | pair, hash |
15
- hash[pair.first] ||= []
16
- hash[pair.first] << pair.last
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
 
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -13,8 +13,8 @@ module Pact
13
13
 
14
14
  let(:difference) do
15
15
  {
16
- "param1" => [Pact::Matchers::Difference.new("foo", "wiffle")],
17
- "param2" => [Pact::Matchers::Difference.new("bar", "foobar"), Pact::Matchers::Difference.new("foobar", "bar")]
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
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: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser