pact 1.0.19 → 1.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@ Do this to generate your change history
2
2
 
3
3
  git log --date=relative --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ ### 1.0.20 (29 October 2013)
6
+
7
+ * c03f34f - Fixed the pretty generation of JSON when active support is loaded. It is both a sad and a happy moment. (Beth, 7 minutes ago)
8
+
5
9
  ### 1.0.19 (29 October 2013)
6
10
  * e4b990e - Gsub '-' to '_' in request headers. (Sebastian Glazebrook, 4 minutes ago)
7
11
  * 52ac8f8 - Added documentation for PACT_DESCRIPTION and PACT_PROVIDER_STATE to README. (Beth, 13 hours ago)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact (1.0.19)
4
+ pact (1.0.20)
5
5
  awesome_print (~> 1.1.0)
6
6
  find_a_port (~> 1.0.1)
7
7
  json
@@ -38,12 +38,15 @@ GEM
38
38
  eventmachine (1.0.3)
39
39
  fakefs (0.4.2)
40
40
  find_a_port (1.0.1)
41
+ geminabox-client (0.0.2)
42
+ multipart-post
41
43
  hashie (2.0.5)
42
44
  i18n (0.6.5)
43
45
  json (1.8.1)
44
46
  method_source (0.8.2)
45
47
  minitest (4.7.5)
46
48
  multi_json (1.8.2)
49
+ multipart-post (1.2.0)
47
50
  pry (0.9.12.2)
48
51
  coderay (~> 1.0.5)
49
52
  method_source (~> 0.8)
@@ -84,6 +87,7 @@ DEPENDENCIES
84
87
  activesupport
85
88
  debugger
86
89
  fakefs (~> 0.4)
90
+ geminabox-client
87
91
  hashie (~> 2.0)
88
92
  pact!
89
93
  pry
@@ -18,6 +18,12 @@ module Pact
18
18
  thing
19
19
  end
20
20
 
21
+ # ActiveSupport JSON overwrites (i.e. TRAMPLES) the json methods of the Regexp class directly
22
+ # (beneath its destructive hooves of destruction).
23
+ # This does not seem to be able to be undone without affecting the JSON serialisation in the
24
+ # calling project, so the best way I've found to fix this issue is to reattach the
25
+ # original as_json to the Regexp instances in the ConsumerContract before we write them to the
26
+ # pact file. If anyone can find a better way, please submit a pull request ASAP!
21
27
  def fix_regexp regexp
22
28
  def regexp.as_json options = {}
23
29
  {:json_class => 'Regexp', "o" => self.options, "s" => self.source }
@@ -25,5 +31,17 @@ module Pact
25
31
  regexp
26
32
  end
27
33
 
34
+ # Having Active Support JSON loaded somehow kills the formatting of pretty_generate for objects.
35
+ # Don't ask me why, but it still seems to work for hashes, so the hacky work around is to
36
+ # reparse the generated JSON into a hash and pretty_generate that... sigh...
37
+ # Oh ActiveSupport, why....
38
+ def fix_json_formatting json
39
+ if json.include?("\n")
40
+ json
41
+ else
42
+ JSON.pretty_generate(JSON.parse(json, create_additions: false))
43
+ end
44
+ end
45
+
28
46
  end
29
47
  end
@@ -139,7 +139,7 @@ module Pact
139
139
  def update_pactfile
140
140
  logger.debug "Updating pact file for #{provider.name} at #{pactfile_path}"
141
141
  File.open(pactfile_path, 'w') do |f|
142
- f.write JSON.pretty_generate(self)
142
+ f.write fix_json_formatting(JSON.pretty_generate(self))
143
143
  end
144
144
  end
145
145
  end
data/lib/pact/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pact
2
- VERSION = "1.0.19"
2
+ VERSION = "1.0.20"
3
3
  end
data/pact.gemspec CHANGED
@@ -35,4 +35,5 @@ Gem::Specification.new do |gem|
35
35
  gem.add_development_dependency 'rspec-fire'
36
36
  gem.add_development_dependency 'activesupport'
37
37
  gem.add_development_dependency 'debugger'
38
+ gem.add_development_dependency 'geminabox-client'
38
39
  end
@@ -39,5 +39,20 @@ module Pact
39
39
  expect(json).to include("{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"alligator\"}")
40
40
  end
41
41
  end
42
+
43
+ describe "fix_json_formatting" do
44
+ let(:active_support_affected_pretty_generated_json) { "{\"json_class\":\"Regexp\",\"o\":0,\"s\":\"a*b\"}" }
45
+ let(:pretty_generated_json) do
46
+ '{
47
+ "json_class": "Regexp",
48
+ "o": 0,
49
+ "s": "a*b"
50
+ }'
51
+ end
52
+
53
+ it "pretty formats the json that has been not pretty formatted because of ActiveSupport" do
54
+ expect(fix_json_formatting(active_support_affected_pretty_generated_json)).to eq (pretty_generated_json.strip)
55
+ end
56
+ end
42
57
  end
43
58
  end
@@ -191,7 +191,7 @@ eos
191
191
  end
192
192
 
193
193
  it "should write the interactions to the file" do
194
- File.read(expected_pact_path).gsub(/\s+/, '').should eql expected_pact_string.strip.gsub(/\s+/, '')
194
+ File.read(expected_pact_path).should eql expected_pact_string.strip
195
195
  end
196
196
  end
197
197
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.0.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -271,6 +271,22 @@ dependencies:
271
271
  - - ! '>='
272
272
  - !ruby/object:Gem::Version
273
273
  version: '0'
274
+ - !ruby/object:Gem::Dependency
275
+ name: geminabox-client
276
+ requirement: !ruby/object:Gem::Requirement
277
+ none: false
278
+ requirements:
279
+ - - ! '>='
280
+ - !ruby/object:Gem::Version
281
+ version: '0'
282
+ type: :development
283
+ prerelease: false
284
+ version_requirements: !ruby/object:Gem::Requirement
285
+ none: false
286
+ requirements:
287
+ - - ! '>='
288
+ - !ruby/object:Gem::Version
289
+ version: '0'
274
290
  description: Define a pact between service consumers and providers
275
291
  email:
276
292
  - james.fraser@alumni.swinburne.edu
@@ -430,15 +446,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
430
446
  - - ! '>='
431
447
  - !ruby/object:Gem::Version
432
448
  version: '0'
449
+ segments:
450
+ - 0
451
+ hash: -2921179149528665156
433
452
  required_rubygems_version: !ruby/object:Gem::Requirement
434
453
  none: false
435
454
  requirements:
436
455
  - - ! '>='
437
456
  - !ruby/object:Gem::Version
438
457
  version: '0'
458
+ segments:
459
+ - 0
460
+ hash: -2921179149528665156
439
461
  requirements: []
440
462
  rubyforge_project:
441
- rubygems_version: 1.8.25
463
+ rubygems_version: 1.8.23
442
464
  signing_key:
443
465
  specification_version: 3
444
466
  summary: Define a pact between service consumers and providers