pact_broker-client 1.2.0 → 1.3.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: 6ce7491eef82209698edba4cb2634ceb83ef69f4
4
- data.tar.gz: 14a3c6d6f84aa3826b68bce12b74528f69e5978d
3
+ metadata.gz: 9a8dab4f53fb2a35fd1d121dfc10c7d6ba07c1ac
4
+ data.tar.gz: 7a32febac80a24893016af889af96c9a33fcad22
5
5
  SHA512:
6
- metadata.gz: d0213fe9b132dcecacff316757703115d2c849ba40dadb9d20ba035df8e269e348fba8dd390d8d8809f23b3aa35e86a6c8e8c33af961813b36e6353311e69fb2
7
- data.tar.gz: 22f7ecc131a2e0ab53bc21700cae9c406d7b52b1c4e5a51eb45657a3f4d8db190fbd674168a70e892a602f94cc3eaf2a9ef4a206717b87884a6bec20b23e578e
6
+ metadata.gz: 20b659f85416883f3649448803ffe5b4f9a93073462df04c635780e376f8e16d2bcce4658bd127a98bbbee07ad057c2009d1b76b0625cac6d03ce92befa12417
7
+ data.tar.gz: 8e0ab94d47be12c18fa995717911a9e03b7c9d562ff5a73c4f076d543f6993516db29dd209103c98e5a4bd4c6222b77727f9a9ffb3f3bbbe3d1b01bec73f33ad
data/CHANGELOG.md CHANGED
@@ -2,6 +2,9 @@ Do this to generate your change history
2
2
 
3
3
  $ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
4
4
 
5
+ #### 1.3.0 (2017-07-03)
6
+ * 138a042 - feat(tag): Added tag to PublicationTask (Beth Skurrie, Mon Jul 3 11:45:24 2017 +1000)
7
+
5
8
  #### 1.2.0 (2016-11-23)
6
9
  * 08e6025 - Fixed broken spec - expected hal+json (Bethany Skurrie, Wed Nov 23 09:20:39 2016 +1100)
7
10
  * ec4b7d7 - Added Travis badge. (Beth Skurrie, Wed Nov 23 09:16:10 2016 +1100)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A client for the Pact Broker. Publishes pacts to, and retrieves pacts from, the pact broker.
4
4
 
5
- [![Build Status](https://travis-ci.org/bethesque/pact_broker-client.svg?branch=master)](https://travis-ci.org/bethesque/pact_broker-client)
5
+ [![Build Status](https://travis-ci.org/pact-foundation/pact_broker-client.svg?branch=master)](https://travis-ci.org/pact-foundation/pact_broker-client)
6
6
 
7
7
  ## Usage
8
8
 
@@ -25,15 +25,26 @@ PactBroker::Client::PublicationTask.new do | task |
25
25
  require 'my_consumer/version'
26
26
  task.consumer_version = MyConsumer::VERSION
27
27
  task.pact_broker_base_url = "http://pact-broker.my.org"
28
+ task.tag = "dev" # optional
28
29
  task.pact_broker_basic_auth = { username: 'basic_auth_user', password: 'basic_auth_pass'} #optional
29
- task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists
30
+ task.write_method = :merge # optional, this will merge the published pact into an existing pact rather than overwriting it if one exists. Not recommended, as it makes a mulch of the workflow on the broker.
30
31
  end
31
32
  ```
32
33
 
34
+ ## Using tags
35
+
36
+ Tags enable you to test different versions of your consumer and provider against each other (eg. `head` and `prod`) and to use pacts on feature branches without breaking your main line of development. You can read more about using tags on the Pact broker [wiki][wiki-tags].
37
+
38
+ If you want to use the git branch name as the tag name, use:
39
+
40
+ ```ruby
41
+ task.tag = `git rev-parse --abbrev-ref HEAD`.strip
42
+ ```
43
+
33
44
  ```bash
34
45
  # In CI script
35
46
 
36
- rake pact:publish
47
+ bundle exec rake pact:publish
37
48
  ```
38
49
 
39
50
  ### Provider
@@ -51,3 +62,5 @@ Pact.service_provider "My Provider" do
51
62
 
52
63
  end
53
64
  ```
65
+
66
+ [wiki-tags]: https://github.com/pact-foundation/pact_broker/wiki/Using-tags
data/RELEASING.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # Releasing
2
2
 
3
3
  1. Increment the version in `lib/pact_broker/client/version.rb`
4
- 2. Update the `CHANGELOG.md` using:
4
+ 2. `bundle exec appraisal update`
5
+ 3. Update the `CHANGELOG.md` using:
5
6
 
6
- $ git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
7
+ $ git log --pretty=format:' * %h - %s (%an, %ad)'
7
8
 
8
- 3. Add files to git
9
+ 4. Add files to git
9
10
 
10
11
  $ git add CHANGELOG.md lib/pact_broker/client/version.rb
11
12
  $ git commit -m "Releasing version X.Y.Z"
12
13
 
13
- 3. Release:
14
+ 5. Release:
14
15
 
15
16
  $ bundle exec rake release
@@ -2,4 +2,4 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gemspec :path => "../"
5
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- pact_broker-client (1.1.1)
4
+ pact_broker-client (1.2.0)
5
5
  httparty
6
6
  json
7
7
  pact
@@ -10,44 +10,41 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- appraisal (1.0.2)
13
+ appraisal (2.2.0)
14
14
  bundler
15
15
  rake
16
16
  thor (>= 0.14.0)
17
17
  awesome_print (1.7.0)
18
18
  coderay (1.1.1)
19
- diff-lcs (1.2.5)
20
- fakefs (0.6.1)
19
+ diff-lcs (1.3)
20
+ fakefs (0.11.0)
21
21
  find_a_port (1.0.1)
22
- httparty (0.13.5)
23
- json (~> 1.8)
22
+ httparty (0.14.0)
24
23
  multi_xml (>= 0.5.2)
25
- json (1.8.3)
24
+ json (2.1.0)
26
25
  method_source (0.8.2)
27
- multi_xml (0.5.5)
28
- pact (1.9.0)
29
- awesome_print (~> 1.1)
30
- find_a_port (~> 1.0.1)
31
- json
32
- pact-mock_service (~> 0.7)
33
- pact-support (~> 0.5)
26
+ multi_xml (0.6.0)
27
+ pact (1.11.1)
28
+ json (> 1.8.5)
29
+ pact-mock_service (~> 1.2)
30
+ pact-support (~> 0.6)
34
31
  rack-test (~> 0.6.2)
35
32
  randexp (~> 0.1.7)
36
33
  rspec (>= 2.14)
37
34
  term-ansicolor (~> 1.0)
38
35
  thor
39
36
  webrick
40
- pact-mock_service (0.7.0)
37
+ pact-mock_service (1.2.0)
41
38
  find_a_port (~> 1.0.1)
42
39
  json
43
- pact-support (~> 0.5)
40
+ pact-support (~> 0.6)
44
41
  rack
45
42
  rack-test (~> 0.6.2)
46
43
  rspec (>= 2.14)
47
44
  term-ansicolor (~> 1.0)
48
45
  thor
49
46
  webrick
50
- pact-support (0.5.1)
47
+ pact-support (0.6.1)
51
48
  awesome_print (~> 1.1)
52
49
  find_a_port (~> 1.0.1)
53
50
  json
@@ -56,35 +53,35 @@ GEM
56
53
  rspec (>= 2.14)
57
54
  term-ansicolor (~> 1.0)
58
55
  thor
59
- pry (0.10.1)
56
+ pry (0.10.4)
60
57
  coderay (~> 1.1.0)
61
58
  method_source (~> 0.8.1)
62
59
  slop (~> 3.4)
63
- rack (1.6.4)
60
+ rack (2.0.2)
64
61
  rack-test (0.6.3)
65
62
  rack (>= 1.0)
66
63
  rake (10.0.4)
67
64
  randexp (0.1.7)
68
- rspec (3.3.0)
69
- rspec-core (~> 3.3.0)
70
- rspec-expectations (~> 3.3.0)
71
- rspec-mocks (~> 3.3.0)
72
- rspec-core (3.3.2)
73
- rspec-support (~> 3.3.0)
74
- rspec-expectations (3.3.1)
65
+ rspec (3.6.0)
66
+ rspec-core (~> 3.6.0)
67
+ rspec-expectations (~> 3.6.0)
68
+ rspec-mocks (~> 3.6.0)
69
+ rspec-core (3.6.0)
70
+ rspec-support (~> 3.6.0)
71
+ rspec-expectations (3.6.0)
75
72
  diff-lcs (>= 1.2.0, < 2.0)
76
- rspec-support (~> 3.3.0)
73
+ rspec-support (~> 3.6.0)
77
74
  rspec-fire (1.3.0)
78
75
  rspec (>= 2.11, < 4)
79
- rspec-mocks (3.3.2)
76
+ rspec-mocks (3.6.0)
80
77
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.3.0)
82
- rspec-support (3.3.0)
78
+ rspec-support (~> 3.6.0)
79
+ rspec-support (3.6.0)
83
80
  slop (3.6.0)
84
- term-ansicolor (1.3.2)
81
+ term-ansicolor (1.6.0)
85
82
  tins (~> 1.0)
86
- thor (0.19.1)
87
- tins (1.12.0)
83
+ thor (0.19.4)
84
+ tins (1.13.2)
88
85
  webrick (1.3.1)
89
86
 
90
87
  PLATFORMS
@@ -97,3 +94,6 @@ DEPENDENCIES
97
94
  pry
98
95
  rake (~> 10.0.3)
99
96
  rspec-fire
97
+
98
+ BUNDLED WITH
99
+ 1.14.6
@@ -4,4 +4,4 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rack", "< 2.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- pact_broker-client (1.1.1)
4
+ pact_broker-client (1.2.0)
5
5
  httparty
6
6
  json
7
7
  pact
@@ -10,44 +10,41 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- appraisal (1.0.2)
13
+ appraisal (2.2.0)
14
14
  bundler
15
15
  rake
16
16
  thor (>= 0.14.0)
17
17
  awesome_print (1.7.0)
18
18
  coderay (1.1.1)
19
- diff-lcs (1.2.5)
20
- fakefs (0.6.1)
19
+ diff-lcs (1.3)
20
+ fakefs (0.11.0)
21
21
  find_a_port (1.0.1)
22
- httparty (0.13.5)
23
- json (~> 1.8)
22
+ httparty (0.14.0)
24
23
  multi_xml (>= 0.5.2)
25
- json (1.8.3)
24
+ json (2.1.0)
26
25
  method_source (0.8.2)
27
- multi_xml (0.5.5)
28
- pact (1.9.0)
29
- awesome_print (~> 1.1)
30
- find_a_port (~> 1.0.1)
31
- json
32
- pact-mock_service (~> 0.7)
33
- pact-support (~> 0.5)
26
+ multi_xml (0.6.0)
27
+ pact (1.11.1)
28
+ json (> 1.8.5)
29
+ pact-mock_service (~> 1.2)
30
+ pact-support (~> 0.6)
34
31
  rack-test (~> 0.6.2)
35
32
  randexp (~> 0.1.7)
36
33
  rspec (>= 2.14)
37
34
  term-ansicolor (~> 1.0)
38
35
  thor
39
36
  webrick
40
- pact-mock_service (0.7.0)
37
+ pact-mock_service (1.2.0)
41
38
  find_a_port (~> 1.0.1)
42
39
  json
43
- pact-support (~> 0.5)
40
+ pact-support (~> 0.6)
44
41
  rack
45
42
  rack-test (~> 0.6.2)
46
43
  rspec (>= 2.14)
47
44
  term-ansicolor (~> 1.0)
48
45
  thor
49
46
  webrick
50
- pact-support (0.5.1)
47
+ pact-support (0.6.1)
51
48
  awesome_print (~> 1.1)
52
49
  find_a_port (~> 1.0.1)
53
50
  json
@@ -56,35 +53,35 @@ GEM
56
53
  rspec (>= 2.14)
57
54
  term-ansicolor (~> 1.0)
58
55
  thor
59
- pry (0.10.1)
56
+ pry (0.10.4)
60
57
  coderay (~> 1.1.0)
61
58
  method_source (~> 0.8.1)
62
59
  slop (~> 3.4)
63
- rack (1.6.4)
60
+ rack (1.6.6)
64
61
  rack-test (0.6.3)
65
62
  rack (>= 1.0)
66
63
  rake (10.0.4)
67
64
  randexp (0.1.7)
68
- rspec (3.3.0)
69
- rspec-core (~> 3.3.0)
70
- rspec-expectations (~> 3.3.0)
71
- rspec-mocks (~> 3.3.0)
72
- rspec-core (3.3.2)
73
- rspec-support (~> 3.3.0)
74
- rspec-expectations (3.3.1)
65
+ rspec (3.6.0)
66
+ rspec-core (~> 3.6.0)
67
+ rspec-expectations (~> 3.6.0)
68
+ rspec-mocks (~> 3.6.0)
69
+ rspec-core (3.6.0)
70
+ rspec-support (~> 3.6.0)
71
+ rspec-expectations (3.6.0)
75
72
  diff-lcs (>= 1.2.0, < 2.0)
76
- rspec-support (~> 3.3.0)
73
+ rspec-support (~> 3.6.0)
77
74
  rspec-fire (1.3.0)
78
75
  rspec (>= 2.11, < 4)
79
- rspec-mocks (3.3.2)
76
+ rspec-mocks (3.6.0)
80
77
  diff-lcs (>= 1.2.0, < 2.0)
81
- rspec-support (~> 3.3.0)
82
- rspec-support (3.3.0)
78
+ rspec-support (~> 3.6.0)
79
+ rspec-support (3.6.0)
83
80
  slop (3.6.0)
84
- term-ansicolor (1.3.2)
81
+ term-ansicolor (1.6.0)
85
82
  tins (~> 1.0)
86
- thor (0.19.1)
87
- tins (1.12.0)
83
+ thor (0.19.4)
84
+ tins (1.13.2)
88
85
  webrick (1.3.1)
89
86
 
90
87
  PLATFORMS
@@ -98,3 +95,6 @@ DEPENDENCIES
98
95
  rack (< 2.0)
99
96
  rake (~> 10.0.3)
100
97
  rspec-fire
98
+
99
+ BUNDLED WITH
100
+ 1.14.6
@@ -6,22 +6,26 @@ module PactBroker
6
6
  module Client
7
7
  class PublishPacts
8
8
 
9
- def initialize pact_broker_base_url, pact_files, consumer_version, pact_broker_client_options={}
9
+ def initialize pact_broker_base_url, pact_files, consumer_version, tag, pact_broker_client_options={}
10
10
  @pact_broker_base_url = pact_broker_base_url
11
11
  @pact_files = pact_files
12
12
  @consumer_version = consumer_version
13
+ @tag = tag
13
14
  @pact_broker_client_options = pact_broker_client_options
14
15
  end
15
16
 
16
17
  def call
17
18
  validate
18
19
  $stdout.puts("")
19
- pact_files.collect{ | pact_file | publish_pact pact_file }.all?
20
+ result = pact_files.collect{ | pact_file | publish_pact pact_file }.all?
21
+ result = result && tag_consumer_version
22
+ $stdout.puts("")
23
+ result
20
24
  end
21
25
 
22
26
  private
23
27
 
24
- attr_reader :pact_broker_base_url, :pact_files, :consumer_version, :pact_broker_client_options
28
+ attr_reader :pact_broker_base_url, :pact_files, :consumer_version, :tag, :pact_broker_client_options
25
29
 
26
30
  def pact_broker_client
27
31
  @pact_broker_client ||= PactBroker::Client::PactBrokerClient.new(base_url: pact_broker_base_url, client_options: pact_broker_client_options)
@@ -37,20 +41,40 @@ module PactBroker
37
41
  end
38
42
  end
39
43
 
44
+ def tag_consumer_version
45
+ return true unless tag
46
+ versions = pact_broker_client.pacticipants.versions
47
+ Retry.until_true do
48
+ $stdout.puts "Tagging version #{consumer_version} of #{consumer_name} as #{tag.inspect}"
49
+ versions.tag(pacticipant: consumer_name, version: consumer_version, tag: tag)
50
+ end
51
+ rescue => e
52
+ $stderr.puts "Failed to tag version #{consumer_version} of #{consumer_name} due to error: #{e.to_s}\n#{e.backtrace.join("\n")}"
53
+ false
54
+ end
55
+
40
56
  def publish_pact_contents(pact_file_contents)
41
57
  Retry.until_true do
42
- contract = ::Pact::ConsumerContract.from_json(pact_file_contents)
58
+ contract = contract_from_file(pact_file_contents)
43
59
  pacts = pact_broker_client.pacticipants.versions.pacts
44
60
  if pacts.version_published?(consumer: contract.consumer.name, provider: contract.provider.name, consumer_version: consumer_version)
45
61
  $stdout.puts ::Term::ANSIColor.yellow("The given version of pact is already published. Will Overwrite...")
46
62
  end
47
63
 
48
64
  latest_pact_url = pacts.publish(pact_json: pact_file_contents, consumer_version: consumer_version)
49
- $stdout.puts "The latest version of this pact can be accessed at the following URL (use this to configure the provider verification):\n#{latest_pact_url}\n\n"
65
+ $stdout.puts "The latest version of this pact can be accessed at the following URL (use this to configure the provider verification):\n#{latest_pact_url}"
50
66
  true
51
67
  end
52
68
  end
53
69
 
70
+ def consumer_name
71
+ contract_from_file(File.read(pact_files.first)).consumer.name
72
+ end
73
+
74
+ def contract_from_file pact_file_contents
75
+ ::Pact::ConsumerContract.from_json(pact_file_contents)
76
+ end
77
+
54
78
  def validate
55
79
  raise "Please specify the consumer_version" unless (consumer_version && consumer_version.to_s.strip.size > 0)
56
80
  raise "Please specify the pact_broker_base_url" unless (pact_broker_base_url && pact_broker_base_url.to_s.strip.size > 0)
@@ -7,6 +7,7 @@ PactBroker::Client::PublicationTask.new do | task |
7
7
  require 'consumer/version'
8
8
  task.pact_broker_base_url = 'http://pact-broker'
9
9
  task.consumer_version = Consumer::VERSION
10
+ task.tag = "dev"
10
11
  end
11
12
 
12
13
  =end
@@ -15,7 +16,7 @@ module PactBroker
15
16
  module Client
16
17
  class PublicationTask < ::Rake::TaskLib
17
18
 
18
- attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :write_method, :pact_broker_basic_auth
19
+ attr_accessor :pattern, :pact_broker_base_url, :consumer_version, :tag, :write_method, :pact_broker_basic_auth
19
20
 
20
21
  def initialize name = nil, &block
21
22
  @name = name
@@ -34,7 +35,7 @@ module PactBroker
34
35
  require 'pact_broker/client/publish_pacts'
35
36
  basic_auth_client_options = pact_broker_basic_auth ? {basic_auth: pact_broker_basic_auth} : {}
36
37
  pact_broker_client_options = basic_auth_client_options.merge(write_method ? {write: write_method} : {})
37
- success = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[pattern], consumer_version, pact_broker_client_options).call
38
+ success = PactBroker::Client::PublishPacts.new(pact_broker_base_url, FileList[pattern], consumer_version, tag, pact_broker_client_options).call
38
39
  raise "One or more pacts failed to be published" unless success
39
40
  end
40
41
  end
@@ -1,5 +1,5 @@
1
1
  module PactBroker
2
2
  module Client
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
5
5
  end
@@ -22,8 +22,10 @@ module PactBroker
22
22
  let(:pact_broker_client) { double("PactBroker::Client")}
23
23
  let(:pact_files) { ['spec/pacts/consumer-provider.json']}
24
24
  let(:consumer_version) { "1.2.3" }
25
+ let(:tag) { nil }
25
26
  let(:pact_hash) { {consumer: {name: 'Consumer'}, provider: {name: 'Provider'}, interactions: [] } }
26
27
  let(:pacts_client) { instance_double("PactBroker::ClientSupport::Pacts")}
28
+ let(:pact_versions_client) { instance_double("PactBroker::Client::Versions", tag: false) }
27
29
  let(:pact_broker_base_url) { 'http://some-host'}
28
30
  let(:pact_broker_client_options) do
29
31
  {
@@ -34,11 +36,12 @@ module PactBroker
34
36
  }
35
37
  end
36
38
 
37
- subject { PublishPacts.new(pact_broker_base_url, pact_files, consumer_version, pact_broker_client_options) }
39
+ subject { PublishPacts.new(pact_broker_base_url, pact_files, consumer_version, tag, pact_broker_client_options) }
38
40
 
39
41
  before do
40
42
  FileUtils.mkdir_p "spec/pacts"
41
43
  File.open("spec/pacts/consumer-provider.json", "w") { |file| file << pact_hash.to_json }
44
+ allow(pact_broker_client).to receive_message_chain(:pacticipants, :versions).and_return(pact_versions_client)
42
45
  allow(pact_broker_client).to receive_message_chain(:pacticipants, :versions, :pacts).and_return(pacts_client)
43
46
  allow(pacts_client).to receive(:version_published?).and_return(false)
44
47
  end
@@ -105,6 +108,33 @@ module PactBroker
105
108
  end
106
109
  end
107
110
 
111
+ context "when a tag is provided" do
112
+ let(:tag) { "dev" }
113
+
114
+ it "tags the consumer version" do
115
+ expect(pact_versions_client).to receive(:tag).with({pacticipant: "Consumer", version: consumer_version, tag: tag})
116
+ subject.call
117
+ end
118
+
119
+ context "when an error occurs tagging the pact" do
120
+
121
+ before do
122
+ allow(pact_versions_client).to receive(:tag).and_raise("an error")
123
+ allow(Retry).to receive(:sleep)
124
+ allow($stderr).to receive(:puts)
125
+ end
126
+
127
+ it "retries multiple times" do
128
+ expect(pact_versions_client).to receive(:tag).exactly(3).times
129
+ subject.call
130
+ end
131
+
132
+ it "returns false" do
133
+ expect(subject.call).to eq false
134
+ end
135
+ end
136
+ end
137
+
108
138
  context "when an error occurs every time while publishing a pact" do
109
139
 
110
140
  before do
@@ -30,7 +30,7 @@ module PactBroker::Client
30
30
 
31
31
  context "when pacts are succesfully published" do
32
32
  it "invokes PublishPacts with the default values" do
33
- PactBroker::Client::PublishPacts.should_receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', {}).and_return(publish_pacts)
33
+ PactBroker::Client::PublishPacts.should_receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', nil, {}).and_return(publish_pacts)
34
34
  publish_pacts.should_receive(:call).and_return(true)
35
35
  Rake::Task['pact:publish'].execute
36
36
  end
@@ -53,7 +53,7 @@ module PactBroker::Client
53
53
  end
54
54
 
55
55
  it "invokes PublishPacts with the write method set" do
56
- PactBroker::Client::PublishPacts.should_receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', {write: :merge}).and_return(publish_pacts)
56
+ PactBroker::Client::PublishPacts.should_receive(:new).with('http://pact-broker', pact_file_list, '1.2.3', nil, {write: :merge}).and_return(publish_pacts)
57
57
  publish_pacts.should_receive(:call).and_return(true)
58
58
  Rake::Task['pact:publish:merge'].execute
59
59
  end
@@ -65,8 +65,10 @@ module PactBroker::Client
65
65
  @pact_broker_base_url = "http://some-host"
66
66
  @pattern = "pact/*.json"
67
67
  @pact_broker_basic_auth = { username: 'user', password: 'pass'}
68
+ @tag = "dev"
68
69
  PactBroker::Client::PublicationTask.new(:custom) do | task |
69
70
  task.consumer_version = '1.2.3'
71
+ task.tag = @tag
70
72
  task.pact_broker_base_url = @pact_broker_base_url
71
73
  task.pattern = @pattern
72
74
  task.pact_broker_basic_auth = @pact_broker_basic_auth
@@ -76,7 +78,7 @@ module PactBroker::Client
76
78
  let(:pattern) { @pattern }
77
79
 
78
80
  it "invokes PublishPacts with the customised values" do
79
- PactBroker::Client::PublishPacts.should_receive(:new).with(@pact_broker_base_url, pact_file_list, '1.2.3', {basic_auth: @pact_broker_basic_auth})
81
+ PactBroker::Client::PublishPacts.should_receive(:new).with(@pact_broker_base_url, pact_file_list, '1.2.3', @tag, {basic_auth: @pact_broker_basic_auth})
80
82
  publish_pacts.should_receive(:call).and_return(true)
81
83
  Rake::Task['pact:publish:custom'].execute
82
84
  end
@@ -8,7 +8,7 @@
8
8
  "interactions": [
9
9
  {
10
10
  "description": "a request to list the latest pacts",
11
- "provider_state": "a pact between Condor and the Pricing Service exists",
11
+ "providerState": "a pact between Condor and the Pricing Service exists",
12
12
  "request": {
13
13
  "method": "get",
14
14
  "path": "/pacts/latest",
@@ -78,7 +78,7 @@
78
78
  },
79
79
  {
80
80
  "description": "a request to list pacticipants",
81
- "provider_state": "'Condor' exists in the pact-broker",
81
+ "providerState": "'Condor' exists in the pact-broker",
82
82
  "request": {
83
83
  "method": "get",
84
84
  "path": "/pacticipants",
@@ -137,7 +137,7 @@
137
137
  },
138
138
  {
139
139
  "description": "a request to get the Pricing Service",
140
- "provider_state": "the 'Pricing Service' already exists in the pact-broker",
140
+ "providerState": "the 'Pricing Service' already exists in the pact-broker",
141
141
  "request": {
142
142
  "method": "get",
143
143
  "path": "/pacticipants/Pricing%20Service",
@@ -188,7 +188,7 @@
188
188
  },
189
189
  {
190
190
  "description": "a request to get the Pricing Service",
191
- "provider_state": "the 'Pricing Service' does not exist in the pact-broker",
191
+ "providerState": "the 'Pricing Service' does not exist in the pact-broker",
192
192
  "request": {
193
193
  "method": "get",
194
194
  "path": "/pacticipants/Pricing%20Service",
@@ -203,7 +203,7 @@
203
203
  },
204
204
  {
205
205
  "description": "a request to publish a pact",
206
- "provider_state": "the 'Pricing Service' already exists in the pact-broker",
206
+ "providerState": "the 'Pricing Service' already exists in the pact-broker",
207
207
  "request": {
208
208
  "method": "put",
209
209
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
@@ -237,7 +237,7 @@
237
237
  },
238
238
  {
239
239
  "description": "a request to publish a pact with method patch",
240
- "provider_state": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
240
+ "providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
241
241
  "request": {
242
242
  "method": "patch",
243
243
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
@@ -271,7 +271,7 @@
271
271
  },
272
272
  {
273
273
  "description": "a request to publish a pact with method put",
274
- "provider_state": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
274
+ "providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
275
275
  "request": {
276
276
  "method": "put",
277
277
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
@@ -305,7 +305,7 @@
305
305
  },
306
306
  {
307
307
  "description": "a request to publish a pact",
308
- "provider_state": "'Condor' already exist in the pact-broker, but the 'Pricing Service' does not",
308
+ "providerState": "'Condor' already exist in the pact-broker, but the 'Pricing Service' does not",
309
309
  "request": {
310
310
  "method": "put",
311
311
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
@@ -339,7 +339,7 @@
339
339
  },
340
340
  {
341
341
  "description": "a request to publish a pact",
342
- "provider_state": "an error occurs while publishing a pact",
342
+ "providerState": "an error occurs while publishing a pact",
343
343
  "request": {
344
344
  "method": "put",
345
345
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
@@ -364,11 +364,11 @@
364
364
  "Content-Type": {
365
365
  "json_class": "Pact::Term",
366
366
  "data": {
367
- "generate": "application/json",
367
+ "generate": "application/hal+json",
368
368
  "matcher": {
369
369
  "json_class": "Regexp",
370
370
  "o": 0,
371
- "s": "application/json"
371
+ "s": "application/.*json"
372
372
  }
373
373
  }
374
374
  }
@@ -390,7 +390,7 @@
390
390
  },
391
391
  {
392
392
  "description": "a request to register the repository URL of a pacticipant",
393
- "provider_state": "the 'Pricing Service' does not exist in the pact-broker",
393
+ "providerState": "the 'Pricing Service' does not exist in the pact-broker",
394
394
  "request": {
395
395
  "method": "patch",
396
396
  "path": "/pacticipants/Pricing%20Service",
@@ -409,7 +409,7 @@
409
409
  },
410
410
  {
411
411
  "description": "a request to register the repository URL of a pacticipant",
412
- "provider_state": "the 'Pricing Service' already exists in the pact-broker",
412
+ "providerState": "the 'Pricing Service' already exists in the pact-broker",
413
413
  "request": {
414
414
  "method": "patch",
415
415
  "path": "/pacticipants/Pricing%20Service",
@@ -428,7 +428,7 @@
428
428
  },
429
429
  {
430
430
  "description": "a request for the list of the latest prod pacts from all consumers for the Pricing Service'",
431
- "provider_state": "tagged as prod pact between Condor and the Pricing Service exists",
431
+ "providerState": "tagged as prod pact between Condor and the Pricing Service exists",
432
432
  "request": {
433
433
  "method": "get",
434
434
  "path": "/pacts/provider/Pricing%20Service/latest/prod",
@@ -443,12 +443,12 @@
443
443
  "_links": {
444
444
  "provider": {
445
445
  "href": "http://example.org/pacticipants/Pricing%20Service",
446
- "title": "Pricing%20Service"
446
+ "title": "Pricing Service"
447
447
  },
448
448
  "pacts": [
449
449
  {
450
450
  "href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
451
- "title": "Pact between Condor (v1.3.0) and Pricing%20Service",
451
+ "title": "Pact between Condor (v1.3.0) and Pricing Service",
452
452
  "name": "Condor"
453
453
  }
454
454
  ]
@@ -458,7 +458,7 @@
458
458
  },
459
459
  {
460
460
  "description": "a request for the list of the latest pacts from all consumers for the Pricing Service'",
461
- "provider_state": "a latest pact between Condor and the Pricing Service exists",
461
+ "providerState": "a latest pact between Condor and the Pricing Service exists",
462
462
  "request": {
463
463
  "method": "get",
464
464
  "path": "/pacts/provider/Pricing%20Service/latest",
@@ -473,12 +473,12 @@
473
473
  "_links": {
474
474
  "provider": {
475
475
  "href": "http://example.org/pacticipants/Pricing%20Service",
476
- "title": "Pricing%20Service"
476
+ "title": "Pricing Service"
477
477
  },
478
478
  "pacts": [
479
479
  {
480
480
  "href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
481
- "title": "Pact between Condor (v1.3.0) and Pricing%20Service",
481
+ "title": "Pact between Condor (v1.3.0) and Pricing Service",
482
482
  "name": "Condor"
483
483
  }
484
484
  ]
@@ -488,7 +488,7 @@
488
488
  },
489
489
  {
490
490
  "description": "a request retrieve a pact for a specific version",
491
- "provider_state": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
491
+ "providerState": "the 'Pricing Service' and 'Condor' already exist in the pact-broker, and Condor already has a pact published for version 1.3.0",
492
492
  "request": {
493
493
  "method": "get",
494
494
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
@@ -514,7 +514,7 @@
514
514
  },
515
515
  {
516
516
  "description": "a request to retrieve the latest pact between Condor and the Pricing Service",
517
- "provider_state": "a pact between Condor and the Pricing Service exists",
517
+ "providerState": "a pact between Condor and the Pricing Service exists",
518
518
  "request": {
519
519
  "method": "get",
520
520
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/latest",
@@ -527,11 +527,11 @@
527
527
  "Content-Type": {
528
528
  "json_class": "Pact::Term",
529
529
  "data": {
530
- "generate": "application/json",
530
+ "generate": "application/hal+json",
531
531
  "matcher": {
532
532
  "json_class": "Regexp",
533
533
  "o": 0,
534
- "s": "application/json"
534
+ "s": "application/.*json"
535
535
  }
536
536
  }
537
537
  },
@@ -552,7 +552,7 @@
552
552
  },
553
553
  {
554
554
  "description": "a request to retrieve the latest pact between Condor and the Pricing Service",
555
- "provider_state": "no pact between Condor and the Pricing Service exists",
555
+ "providerState": "no pact between Condor and the Pricing Service exists",
556
556
  "request": {
557
557
  "method": "get",
558
558
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/latest",
@@ -567,7 +567,7 @@
567
567
  },
568
568
  {
569
569
  "description": "a request to retrieve the pact between the production verison of Condor and the Pricing Service",
570
- "provider_state": "a pact between Condor and the Pricing Service exists for the production version of Condor",
570
+ "providerState": "a pact between Condor and the Pricing Service exists for the production version of Condor",
571
571
  "request": {
572
572
  "method": "get",
573
573
  "path": "/pacts/provider/Pricing%20Service/consumer/Condor/latest/prod",
@@ -594,7 +594,7 @@
594
594
  },
595
595
  {
596
596
  "description": "a request to tag the production version of Condor",
597
- "provider_state": "'Condor' exists in the pact-broker",
597
+ "providerState": "'Condor' exists in the pact-broker",
598
598
  "request": {
599
599
  "method": "put",
600
600
  "path": "/pacticipants/Condor/versions/1.3.0/tags/prod",
@@ -627,7 +627,7 @@
627
627
  },
628
628
  {
629
629
  "description": "a request to tag the production version of Condor",
630
- "provider_state": "'Condor' does not exist in the pact-broker",
630
+ "providerState": "'Condor' does not exist in the pact-broker",
631
631
  "request": {
632
632
  "method": "put",
633
633
  "path": "/pacticipants/Condor/versions/1.3.0/tags/prod",
@@ -660,7 +660,7 @@
660
660
  },
661
661
  {
662
662
  "description": "a request to tag the production version of Condor",
663
- "provider_state": "'Condor' exists in the pact-broker with version 1.3.0, tagged with 'prod'",
663
+ "providerState": "'Condor' exists in the pact-broker with version 1.3.0, tagged with 'prod'",
664
664
  "request": {
665
665
  "method": "put",
666
666
  "path": "/pacticipants/Condor/versions/1.3.0/tags/prod",
@@ -693,6 +693,8 @@
693
693
  }
694
694
  ],
695
695
  "metadata": {
696
- "pactSpecificationVersion": "1.0.0"
696
+ "pactSpecification": {
697
+ "version": "1.0.0"
698
+ }
697
699
  }
698
700
  }
@@ -114,7 +114,7 @@ module PactBroker::Client
114
114
  body: pact_hash ).
115
115
  will_respond_with(
116
116
  status: 500,
117
- headers: {'Content-Type' => Pact.term(generate: 'application/json', matcher: %r{application/json})},
117
+ headers: {'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/.*json})},
118
118
  body: {
119
119
  message: Pact::Term.new(matcher: /.*/, generate: 'An error occurred')
120
120
  }
@@ -33,7 +33,7 @@ module PactBroker::Client
33
33
 
34
34
  let(:response_headers) do
35
35
  pact_broker_response_headers.merge(
36
- 'Content-Type' => Pact.term(generate: 'application/json', matcher: %r{application/json}),
36
+ 'Content-Type' => Pact.term(generate: 'application/hal+json', matcher: %r{application/.*json}),
37
37
  'X-Pact-Consumer-Version' => consumer_version
38
38
  )
39
39
  end
@@ -2,12 +2,12 @@
2
2
  "_links": {
3
3
  "provider": {
4
4
  "href": "http://example.org/pacticipants/Pricing%20Service",
5
- "title": "Pricing%20Service"
5
+ "title": "Pricing Service"
6
6
  },
7
7
  "pacts": [
8
8
  {
9
9
  "href": "http://example.org/pacts/provider/Pricing%20Service/consumer/Condor/version/1.3.0",
10
- "title": "Pact between Condor (v1.3.0) and Pricing%20Service",
10
+ "title": "Pact between Condor (v1.3.0) and Pricing Service",
11
11
  "name": "Condor"
12
12
  }
13
13
  ]
data/tasks/pact.rake CHANGED
@@ -1,7 +1,16 @@
1
1
  require 'pact_broker/client/tasks'
2
2
 
3
- PactBroker::Client::PublicationTask.new do | task |
3
+ PactBroker::Client::PublicationTask.new(:localhost) do | task |
4
4
  require 'pact_broker/client/version'
5
+ task.tag = `git rev-parse --abbrev-ref HEAD`.strip
5
6
  task.consumer_version = PactBroker::Client::VERSION
6
7
  task.pact_broker_base_url = "http://localhost:9292"
7
- end
8
+ end
9
+
10
+ PactBroker::Client::PublicationTask.new(:remote) do | task |
11
+ require 'pact_broker/client/version'
12
+ task.tag = `git rev-parse --abbrev-ref HEAD`.strip
13
+ task.consumer_version = PactBroker::Client::VERSION
14
+ task.pact_broker_base_url = "https://test.pact.dius.com.au"
15
+ task.pact_broker_basic_auth = {username: ENV.fetch('PACT_BROKER_USERNAME'), password: ENV.fetch('PACT_BROKER_PASSWORD')}
16
+ end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact_broker-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bethany Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pact
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: term-ansicolor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 10.0.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 10.0.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: fakefs
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0.4'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0.4'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rspec-fire
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: appraisal
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: Publishes pacts to, and retrieves pacts from, the pact broker server.
@@ -143,9 +143,9 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - .gitignore
147
- - .rspec
148
- - .travis.yml
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
149
149
  - Appraisals
150
150
  - CHANGELOG.md
151
151
  - Gemfile
@@ -204,17 +204,17 @@ require_paths:
204
204
  - lib
205
205
  required_ruby_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - '>='
207
+ - - ">="
208
208
  - !ruby/object:Gem::Version
209
209
  version: '2.0'
210
210
  required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - '>='
212
+ - - ">="
213
213
  - !ruby/object:Gem::Version
214
214
  version: '0'
215
215
  requirements: []
216
216
  rubyforge_project:
217
- rubygems_version: 2.0.14
217
+ rubygems_version: 2.6.11
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: See description