pact-support 0.0.3 → 0.0.4

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: c22fbc42f806850fdf59aae86c0ab60221e53b31
4
- data.tar.gz: d861be0013364c930b5d092caa37fab70a3d9c5c
3
+ metadata.gz: 9c27327d015a0d365e6fb40d46bfaf51988a54bf
4
+ data.tar.gz: 8f8c448fd177b5aca19761c205cc3c94d8ceecdb
5
5
  SHA512:
6
- metadata.gz: ce97bbeb237b4ed9dd74251120aab5a1ad6a452057c0fdf4f7236c811fe35a944bc3a89263983782bbc304104ea2e2f36b37a2b40c0455cf8c647ad26e0c249e
7
- data.tar.gz: 92b643e2648be79ccf6e7221d7d3a30e3a735fe6cc04f0cede398a7ac6bc720a3d0564d8da9ade013003d616c87b39ae1bff815bb7d8dbb5346f8cb3764b4d0c
6
+ metadata.gz: 216d7e4778f28365ef8c22a3916a9bfc9d54bcc885e9f0c997938afbaf9a63b5d853f8d1a458caef2973c8874558551fa8fe923edb6ac789fe2bac0202a89e6a
7
+ data.tar.gz: a5cab6e546286061eabbd519163ed7ced91683ac4d2c9e5192e60cc15c8e3583349a595b32237bcbde4a8076e3fdded6b969e33adbe630261343aca29c85492e
@@ -2,16 +2,20 @@ Do this to generate your change history
2
2
 
3
3
  git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ### 0.0.4 (20 October 2014)
6
+
7
+ * ebe5e32 - Added differ for application/x-www-form-urlencoded bodies. (bethesque, Mon Oct 20 20:26:13 2014 +1100)
8
+
5
9
  ### 0.0.3 (17 October 2014)
6
10
 
7
11
  * bab0b34 - Added possibility to provide queries as Hash. Then order of parameters in the query is not longer relevant. (André Allavena, Tue Oct 14 00:24:38 2014 +1000)
8
12
 
9
13
  ### 0.0.2 (12 October 2014)
10
14
 
11
- * e7080fe - Added a QueryString class in preparation for a QueryHash class (Beth, Sun Oct 12 14:32:15 2014 +1100)
12
- * 8839151 - Added Travis config (Beth, Sun Oct 12 12:31:44 2014 +1100)
13
- * 81ade54 - Removed CLI (Beth, Sun Oct 12 12:29:22 2014 +1100)
14
- * 3bdde98 - Removing unused files (Beth, Sun Oct 12 12:11:48 2014 +1100)
15
- * ef95717 - Made it build (Beth, Sat Oct 11 13:24:35 2014 +1100)
16
- * 1e78b62 - Removed pact-test.rake (Beth, Sat Oct 11 13:20:49 2014 +1100)
17
- * 3389b5e - Initial commit (Beth, Sat Oct 11 13:13:23 2014 +1100)
15
+ * e7080fe - Added a QueryString class in preparation for a QueryHash class (Beth, Sun Oct 12 14:32:15 2014 +1100)
16
+ * 8839151 - Added Travis config (Beth, Sun Oct 12 12:31:44 2014 +1100)
17
+ * 81ade54 - Removed CLI (Beth, Sun Oct 12 12:29:22 2014 +1100)
18
+ * 3bdde98 - Removing unused files (Beth, Sun Oct 12 12:11:48 2014 +1100)
19
+ * ef95717 - Made it build (Beth, Sat Oct 11 13:24:35 2014 +1100)
20
+ * 1e78b62 - Removed pact-test.rake (Beth, Sat Oct 11 13:20:49 2014 +1100)
21
+ * 3389b5e - Initial commit (Beth, Sat Oct 11 13:13:23 2014 +1100)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact-support (0.0.3)
4
+ pact-support (0.0.4)
5
5
  awesome_print (~> 1.1)
6
6
  find_a_port (~> 1.0.1)
7
7
  json
@@ -3,6 +3,7 @@ require 'pact/matchers/unix_diff_formatter'
3
3
  require 'pact/matchers/list_diff_formatter'
4
4
  require 'pact/shared/json_differ'
5
5
  require 'pact/shared/text_differ'
6
+ require 'pact/shared/form_differ'
6
7
 
7
8
 
8
9
  module Pact
@@ -29,6 +30,7 @@ module Pact
29
30
 
30
31
  DIFFERS = [
31
32
  [/json/, Pact::JsonDiffer],
33
+ [/application\/x\-www\-form\-urlencoded/, Pact::FormDiffer],
32
34
  [NilMatcher, Pact::TextDiffer],
33
35
  [/.*/, Pact::TextDiffer]
34
36
  ]
@@ -95,6 +97,15 @@ module Pact
95
97
  log_dir + "/pact.log"
96
98
  end
97
99
 
100
+ def color_enabled
101
+ # Can't use ||= when the variable might be false, it will execute the expression if it's false
102
+ defined?(@color_enabled) ? @color_enabled : true
103
+ end
104
+
105
+ def color_enabled= color_enabled
106
+ @color_enabled = color_enabled
107
+ end
108
+
98
109
  private
99
110
 
100
111
  def diff_formatter_for input
@@ -67,10 +67,10 @@ module Pact
67
67
 
68
68
  def body_diff(actual_body)
69
69
  if specified?(:body)
70
- body_differ.call({:body => body}, {body: actual_body}, allow_unexpected_keys: runtime_options[:allow_unexpected_keys_in_body])
71
- else
72
- {}
70
+ body_difference = body_differ.call(body, actual_body, allow_unexpected_keys: runtime_options[:allow_unexpected_keys_in_body])
71
+ return { body: body_difference } if body_difference.any?
73
72
  end
73
+ {}
74
74
  end
75
75
 
76
76
  def body_differ
@@ -0,0 +1,21 @@
1
+ require 'pact/matchers/matchers'
2
+ require 'uri'
3
+
4
+ module Pact
5
+ class FormDiffer
6
+
7
+ extend Matchers
8
+
9
+ def self.call expected, actual, options = {}
10
+ diff to_hash(expected), to_hash(actual), options
11
+ end
12
+
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
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Support
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+ require 'pact/configuration'
3
+
4
+ module Pact
5
+
6
+ describe Configuration do
7
+
8
+ subject { Configuration.default_configuration }
9
+
10
+ describe "#color_enabled" do
11
+
12
+ it "sets color_enabled to be true by default" do
13
+ expect(subject.color_enabled).to be true
14
+ end
15
+
16
+ it "allows configuration of colour_enabled" do
17
+ subject.color_enabled = false
18
+ expect(subject.color_enabled).to be false
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'pact/shared/form_differ'
3
+ require 'pact/matchers/difference'
4
+ require 'pact/matchers/unix_diff_formatter'
5
+
6
+ module Pact
7
+ describe FormDiffer do
8
+
9
+ describe ".call" do
10
+
11
+ let(:expected) { "param1=foo&param2=bar&param2=foobar" }
12
+ let(:actual) { "param1=wiffle&param2=foobar&param2=bar" }
13
+
14
+ let(:difference) do
15
+ {
16
+ "param1" => [Pact::Matchers::Difference.new("foo", "wiffle")],
17
+ "param2" => [Pact::Matchers::Difference.new("bar", "foobar"), Pact::Matchers::Difference.new("foobar", "bar")]
18
+ }
19
+ end
20
+
21
+ subject { FormDiffer.call(expected, actual) }
22
+
23
+ context "when there is a diff" do
24
+ it "returns the diff" do
25
+ expect(subject).to eq difference
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ 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.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-10-17 00:00:00.000000000 Z
15
+ date: 2014-10-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
@@ -267,6 +267,7 @@ files:
267
267
  - lib/pact/rspec.rb
268
268
  - lib/pact/shared/active_support_support.rb
269
269
  - lib/pact/shared/dsl.rb
270
+ - lib/pact/shared/form_differ.rb
270
271
  - lib/pact/shared/jruby_support.rb
271
272
  - lib/pact/shared/json_differ.rb
272
273
  - lib/pact/shared/key_not_found.rb
@@ -280,6 +281,7 @@ files:
280
281
  - lib/pact/term.rb
281
282
  - lib/tasks/pact.rake
282
283
  - pact-support.gemspec
284
+ - spec/lib/pact/configuration_spec.rb
283
285
  - spec/lib/pact/consumer/request_spec.rb
284
286
  - spec/lib/pact/consumer_contract/active_support_support_spec.rb
285
287
  - spec/lib/pact/consumer_contract/consumer_contract_spec.rb
@@ -301,6 +303,7 @@ files:
301
303
  - spec/lib/pact/matchers/unix_diff_formatter_spec.rb
302
304
  - spec/lib/pact/reification_spec.rb
303
305
  - spec/lib/pact/shared/dsl_spec.rb
306
+ - spec/lib/pact/shared/form_differ_spec.rb
304
307
  - spec/lib/pact/shared/json_differ_spec.rb
305
308
  - spec/lib/pact/shared/key_not_found_spec.rb
306
309
  - spec/lib/pact/shared/request_spec.rb
@@ -355,6 +358,7 @@ signing_key:
355
358
  specification_version: 4
356
359
  summary: Shared code for Pact gems
357
360
  test_files:
361
+ - spec/lib/pact/configuration_spec.rb
358
362
  - spec/lib/pact/consumer/request_spec.rb
359
363
  - spec/lib/pact/consumer_contract/active_support_support_spec.rb
360
364
  - spec/lib/pact/consumer_contract/consumer_contract_spec.rb
@@ -376,6 +380,7 @@ test_files:
376
380
  - spec/lib/pact/matchers/unix_diff_formatter_spec.rb
377
381
  - spec/lib/pact/reification_spec.rb
378
382
  - spec/lib/pact/shared/dsl_spec.rb
383
+ - spec/lib/pact/shared/form_differ_spec.rb
379
384
  - spec/lib/pact/shared/json_differ_spec.rb
380
385
  - spec/lib/pact/shared/key_not_found_spec.rb
381
386
  - spec/lib/pact/shared/request_spec.rb