pact 1.18.0 → 1.19.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3564518bc269d6ebff3e3139b4798378e3d4fb43
4
- data.tar.gz: d201c44bdea8884cd85abefb6dbafcd473a6220f
3
+ metadata.gz: d10f4cf98866584ab730653b049d9bec27845dfd
4
+ data.tar.gz: 1964e13278474b1343a5f8cd96b2ea58cf60cd35
5
5
  SHA512:
6
- metadata.gz: 1e1f6c4322879bcd163ce37fb799f0c25b366277466501e64ccd0e47022b305413242cb81f4a72c920b1ef31ace6fa195d1469785e70c709d8d76c8505468158
7
- data.tar.gz: 1b8d60f2a005cd7ed2710a5a0d87749927d213f8c31340290186817fadbc71aa7f56e7b91f278dc7c4848cbe910ce6a75261bae61d02e26d9c36e9a1ae129458
6
+ metadata.gz: 5b937d2e132eff171932150b0cabe8711c6f9af52b7eb964e94c05c257e946c090070083962d503e828b9c9c475a0440cf49c3dff5887f551913d3598d508a4d
7
+ data.tar.gz: a60dd39b54c749f2dd24952cdc22399812dd029410df2d94f1f9692c4d45ca7cad5580eb7ef3e0e87f728e6e50a5a8bd85198e4a18f6389108b89d192b22aa05
@@ -1,6 +1,12 @@
1
- Do this to generate your change history
1
+ <a name="v1.19.0"></a>
2
+ ### v1.19.0 (2017-10-30)
3
+
4
+
5
+ #### Features
6
+
7
+ * **verifications**
8
+ * allow provider version tags to be specified ([bff4611](/../../commit/bff4611))
2
9
 
3
- git log --pretty=format:' * %h - %s (%an, %ad)'
4
10
 
5
11
  <a name="v1.18.0"></a>
6
12
  ## 1.18.0 (2017-10-30)
@@ -5,8 +5,9 @@ module Pact
5
5
 
6
6
  attr_accessor :application_version
7
7
 
8
- def initialize application_version, publish_verification_results, &app_block
8
+ def initialize application_version, tags, publish_verification_results, &app_block
9
9
  @application_version = application_version
10
+ @tags = [*tags]
10
11
  @publish_verification_results = publish_verification_results
11
12
  @app_block = app_block
12
13
  end
@@ -18,6 +19,10 @@ module Pact
18
19
  def publish_verification_results?
19
20
  @publish_verification_results
20
21
  end
22
+
23
+ def tags
24
+ @tags
25
+ end
21
26
  end
22
27
  end
23
28
  end
@@ -13,7 +13,7 @@ module Pact
13
13
 
14
14
  extend Pact::DSL
15
15
 
16
- attr_accessor :name, :app_block, :application_version, :publish_verification_results
16
+ attr_accessor :name, :app_block, :application_version, :tags, :publish_verification_results
17
17
 
18
18
  CONFIG_RU_APP = lambda {
19
19
  unless File.exist? Pact.configuration.config_ru_path
@@ -25,6 +25,7 @@ module Pact
25
25
  def initialize name
26
26
  @name = name
27
27
  @publish_verification_results = false
28
+ @tags = []
28
29
  @app_block = CONFIG_RU_APP
29
30
  end
30
31
 
@@ -37,6 +38,10 @@ module Pact
37
38
  self.application_version = application_version
38
39
  end
39
40
 
41
+ def app_version_tags tags
42
+ self.tags = tags
43
+ end
44
+
40
45
  def publish_verification_results publish_verification_results
41
46
  self.publish_verification_results = publish_verification_results
42
47
  Pact::RSpec.with_rspec_2 do
@@ -70,7 +75,7 @@ module Pact
70
75
  end
71
76
 
72
77
  def create_service_provider
73
- Pact.configuration.provider = ServiceProviderConfig.new(application_version, publish_verification_results, &@app_block)
78
+ Pact.configuration.provider = ServiceProviderConfig.new(application_version, tags, publish_verification_results, &@app_block)
74
79
  end
75
80
  end
76
81
  end
@@ -1,6 +1,9 @@
1
1
  require 'json'
2
2
  require 'pact/errors'
3
3
 
4
+ # TODO move this to the pact broker client
5
+ # TODO retries
6
+
4
7
  module Pact
5
8
  module Provider
6
9
  module VerificationResults
@@ -20,6 +23,11 @@ module Pact
20
23
 
21
24
  def call
22
25
  if Pact.configuration.provider.publish_verification_results?
26
+ if tag_url('')
27
+ tag
28
+ else
29
+ Pact.configuration.error_stream.puts "WARN: Cannot tag provider version as there is no link named pb:tag-version in the pact JSON."
30
+ end
23
31
  if publication_url
24
32
  publish
25
33
  else
@@ -34,11 +42,35 @@ module Pact
34
42
  @publication_url ||= pact_source.pact_hash.fetch('_links', {}).fetch('pb:publish-verification-results', {})['href']
35
43
  end
36
44
 
45
+ def tag_url tag
46
+ href = pact_source.pact_hash.fetch('_links', {}).fetch('pb:tag-version', {})['href']
47
+ href ? href.gsub('{tag}', tag) : nil
48
+ end
49
+
50
+ def tag
51
+ Pact.configuration.provider.tags.each do | tag |
52
+ uri = URI(tag_url(tag))
53
+ request = build_request('Put', uri, nil, "Tagging provider version at")
54
+ response = nil
55
+ begin
56
+ options = {:use_ssl => uri.scheme == 'https'}
57
+ response = Net::HTTP.start(uri.host, uri.port, options) do |http|
58
+ http.request request
59
+ end
60
+ rescue StandardError => e
61
+ error_message = "Failed to tag provider version due to: #{e.class} #{e.message}"
62
+ raise PublicationError.new(error_message)
63
+ end
64
+
65
+ unless response.code.start_with?("2")
66
+ raise PublicationError.new("Error returned from tagging request #{response.code} #{response.body}")
67
+ end
68
+ end
69
+ end
70
+
37
71
  def publish
38
- #TODO https
39
- #TODO username/password
40
72
  uri = URI(publication_url)
41
- request = build_request(uri)
73
+ request = build_request('Post', uri, verification_result.to_json, "Publishing verification result #{verification_result.to_json} to")
42
74
  response = nil
43
75
  begin
44
76
  options = {:use_ssl => uri.scheme == 'https'}
@@ -55,16 +87,16 @@ module Pact
55
87
  end
56
88
  end
57
89
 
58
- def build_request uri
59
- request = Net::HTTP::Post.new(uri.path)
90
+ def build_request meth, uri, body, action
91
+ request = Net::HTTP.const_get(meth).new(uri.path)
60
92
  request['Content-Type'] = "application/json"
61
- request.body = verification_result.to_json
93
+ request.body = body if body
62
94
  debug_uri = uri
63
95
  if pact_source.uri.basic_auth?
64
96
  request.basic_auth pact_source.uri.username, pact_source.uri.password
65
97
  debug_uri = URI(uri.to_s).tap { |x| x.userinfo="#{pact_source.uri.username}:*****"}
66
98
  end
67
- Pact.configuration.output_stream.puts "INFO: Publishing verification result #{verification_result.to_json} to #{debug_uri}"
99
+ Pact.configuration.output_stream.puts "INFO: #{action} #{debug_uri}"
68
100
  request
69
101
  end
70
102
 
@@ -15,6 +15,7 @@ module Pact
15
15
  @rspec_summary = rspec_summary
16
16
  end
17
17
 
18
+ # TODO do not publish unless all interactions have been run
18
19
  def call
19
20
  verification_results.collect do | pair |
20
21
  Publish.call(pair.first, pair.last)
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "1.18.0"
3
+ VERSION = "1.19.0"
4
4
  end
@@ -31,5 +31,4 @@ namespace :pact do
31
31
  require 'pact/provider/help/console_text'
32
32
  puts Pact::Provider::Help::ConsoleText.(args[:reports_dir])
33
33
  end
34
-
35
34
  end
@@ -37,6 +37,8 @@ Gem::Specification.new do |gem|
37
37
  gem.add_development_dependency 'fakefs', '0.5' # 0.6.0 blows up
38
38
  gem.add_development_dependency 'hashie', '~> 2.0'
39
39
  gem.add_development_dependency 'activesupport'
40
- gem.add_development_dependency 'faraday'
41
- gem.add_development_dependency 'appraisal'
40
+ gem.add_development_dependency 'faraday', '~> 0.13'
41
+ gem.add_development_dependency 'appraisal', '~> 2.2'
42
+ gem.add_development_dependency 'conventional-changelog', '~> 1.3'
43
+ gem.add_development_dependency 'bump', '~> 0.5'
42
44
  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.18.0
4
+ version: 1.19.0
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: 2017-10-29 00:00:00.000000000 Z
15
+ date: 2017-10-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: randexp
@@ -240,30 +240,58 @@ dependencies:
240
240
  name: faraday
241
241
  requirement: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - ">="
243
+ - - "~>"
244
244
  - !ruby/object:Gem::Version
245
- version: '0'
245
+ version: '0.13'
246
246
  type: :development
247
247
  prerelease: false
248
248
  version_requirements: !ruby/object:Gem::Requirement
249
249
  requirements:
250
- - - ">="
250
+ - - "~>"
251
251
  - !ruby/object:Gem::Version
252
- version: '0'
252
+ version: '0.13'
253
253
  - !ruby/object:Gem::Dependency
254
254
  name: appraisal
255
255
  requirement: !ruby/object:Gem::Requirement
256
256
  requirements:
257
- - - ">="
257
+ - - "~>"
258
258
  - !ruby/object:Gem::Version
259
- version: '0'
259
+ version: '2.2'
260
260
  type: :development
261
261
  prerelease: false
262
262
  version_requirements: !ruby/object:Gem::Requirement
263
263
  requirements:
264
- - - ">="
264
+ - - "~>"
265
265
  - !ruby/object:Gem::Version
266
- version: '0'
266
+ version: '2.2'
267
+ - !ruby/object:Gem::Dependency
268
+ name: conventional-changelog
269
+ requirement: !ruby/object:Gem::Requirement
270
+ requirements:
271
+ - - "~>"
272
+ - !ruby/object:Gem::Version
273
+ version: '1.3'
274
+ type: :development
275
+ prerelease: false
276
+ version_requirements: !ruby/object:Gem::Requirement
277
+ requirements:
278
+ - - "~>"
279
+ - !ruby/object:Gem::Version
280
+ version: '1.3'
281
+ - !ruby/object:Gem::Dependency
282
+ name: bump
283
+ requirement: !ruby/object:Gem::Requirement
284
+ requirements:
285
+ - - "~>"
286
+ - !ruby/object:Gem::Version
287
+ version: '0.5'
288
+ type: :development
289
+ prerelease: false
290
+ version_requirements: !ruby/object:Gem::Requirement
291
+ requirements:
292
+ - - "~>"
293
+ - !ruby/object:Gem::Version
294
+ version: '0.5'
267
295
  description: Enables consumer driven contract testing, providing a mock service and
268
296
  DSL for the consumer project, and interaction playback and verification for the
269
297
  service provider project.
@@ -379,7 +407,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
379
407
  version: '0'
380
408
  requirements: []
381
409
  rubyforge_project:
382
- rubygems_version: 2.6.12
410
+ rubygems_version: 2.6.11
383
411
  signing_key:
384
412
  specification_version: 4
385
413
  summary: Enables consumer driven contract testing, providing a mock service and DSL