pact-message 0.6.0 → 0.7.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
- SHA1:
3
- metadata.gz: 26c0cea21dd41b6f907a255478162aaa8cd51cca
4
- data.tar.gz: b62a0f0fb8e0d13abbd996ca86b9ae826ae032b2
2
+ SHA256:
3
+ metadata.gz: d44fac4a872e57e964a935d228261c50773a4f90249bcdd979420b390b057b73
4
+ data.tar.gz: ea1c430bf254ae94970eaedb568d578cab98d1e68d6ad9e0dcd16322e0775eb1
5
5
  SHA512:
6
- metadata.gz: f816074ffebe0ea7d9a89c21bb971ddee873e67b9a8f872e2077e64ac9e610831c4578680a057e62b719b8de64016c6c76932a377d09e0221615bb3588d069f4
7
- data.tar.gz: d64e741d000004653b13b760ad3be4a2cb49a3bc64b45b45d50cf04e9f28b158d4c06cd808206b9729f183870097ef4eba45e7c2f4d049394791eeb9c92f3957
6
+ metadata.gz: 4c9e77894059e089b6f3239727abe57425b2256d203b2ed6d66a6ee3b94f6ba063b9871198c18ace55dfb74a7d8c1d509f9ee17076df4d89c87657999a26b2fd
7
+ data.tar.gz: 0230fe4dde29531395c5a8153ecf6e718669c412e0088e4eb957131d5c55a64ea4d7eaffc441816b7a8d9c1fa838ee798ee4148a7857e53736534616bc3ef8d5
@@ -1,12 +1,33 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
5
- before_install: gem install bundler -v 1.15.4
4
+ - 2.2.4
5
+ before_install:
6
+ - rvm use @global
7
+ - gem uninstall bundler -x || gem uninstall bundler -a || true
8
+ - gem install bundler -v 1.17.3
9
+ - bundler --version
10
+ script:
11
+ - rvm use @global
12
+ - bundle exec rake
13
+ jobs:
14
+ include:
15
+ - stage: gem release
16
+ rvm: 2.2.4
17
+ script: echo "Deploying to rubygems.org ..."
18
+ deploy:
19
+ provider: rubygems
20
+ api_key:
21
+ secure: NEA7BYENheSN8qF/6BP52uQjTS5U43MXsyxBeqxbp1JOkJxVSNzQw14xy41aXX0gphT7wEVHinnWS+1slLKXvu4OzGKKzcUsnekYFZoGW7eTyKUx7lh/XtFejQ/Mm4P5t75GBgMoaIi+Pa1rD4fcE7zYGrgCvTwIrOGb/SPIKILj0yT8UXMFod8yDDmxzivSSKYe4rgWYlq8aiidDZr2M5ypBR4WcOptCrkBCF8XxXzhFMY4QtrXLsLFRyCzCrDHmosCfC/bLJQltlJjLXfB5ksgaImWAD7wZ6Q4uC5QqmPShonQiPlLEh53Q5nkEWPIcsV7FVZqzXUjPN3LYHlRv+7D3AvbHmJggSt7fXr8YxbzVUkviBlKqNmc9cqM6CSO++QT3UShNgH5b03YKI8rRjFMWYKn1DrN5F5rFNDoGFcZtQSjFN5g/fEiSYsdkNsIeTp4YFxMkTztAYT8TxgcBvCnfXox6xDaLaPWh13UrUL2VL7O7uDK06xWUCp9Hm3/AXz0wRzya1tK9dCWamE5BOzk2ScOiLOgmpgwNHFVA1U93rkHq7Ixr11wazP3Dcinv0kWcW7hdMcI7VA0DUesxLKw6mkcQpd3NLgSU4mWtpoVFcmdERQUGsNM1d5NjGjBeyVMpC0I9NXM1Wv6cLENSX9b4GR7lkwGG/IHRFNciHk=
22
+ gem: pact-message
23
+ on:
24
+ tags: true
25
+ repo: pact-foundation/pact-message-ruby
6
26
  notifications:
7
27
  webhooks:
8
28
  urls:
9
- - https://webhooks.gitter.im/e/6523128341fad111ed79
29
+ - https://webhooks.gitter.im/e/6523128341fad111ed79
10
30
  on_success: change
11
31
  on_failure: always
12
32
  on_start: never
33
+
@@ -1,3 +1,33 @@
1
+ <a name="v0.7.0"></a>
2
+ ### v0.7.0 (2020-02-10)
3
+
4
+
5
+ #### Features
6
+
7
+ * Add metadata to a message request ([796590f](/../../commit/796590f))
8
+ * support the _id attribute from the Pact Broker, and give each message an index ([3a05501](/../../commit/3a05501))
9
+
10
+
11
+ #### Bug Fixes
12
+
13
+ * add back support for using providerState instead of providerStates when updating a pact ([b494a76](/../../commit/b494a76))
14
+
15
+
16
+ <a name="v0.6.0"></a>
17
+ ### v0.6.0 (2020-02-10)
18
+
19
+
20
+ #### Features
21
+
22
+ * Add metadata to a message request ([796590f](/../../commit/796590f))
23
+ * support the _id attribute from the Pact Broker, and give each message an index ([3a05501](/../../commit/3a05501))
24
+
25
+
26
+ #### Bug Fixes
27
+
28
+ * add back support for using providerState instead of providerStates when updating a pact ([b494a76](/../../commit/b494a76))
29
+
30
+
1
31
  <a name="v0.5.0"></a>
2
32
  ### v0.5.0 (2018-10-04)
3
33
 
@@ -0,0 +1,15 @@
1
+ FROM ruby:2.2.4-alpine
2
+
3
+ # Installation path
4
+ ENV HOME=/app
5
+ WORKDIR $HOME
6
+
7
+ RUN set -ex && \
8
+ adduser -h $HOME -s /bin/false -D -S -G root ruby && \
9
+ chmod g+w $HOME && \
10
+ apk add --update --no-cache make gcc libc-dev git
11
+
12
+ RUN gem install bundler -v 1.17.3
13
+ COPY Gemfile pact-message.gemspec $HOME/
14
+ COPY lib/pact/message/version.rb $HOME/lib/pact/message/version.rb
15
+ RUN bundle install --no-cache
data/README.md CHANGED
@@ -4,13 +4,14 @@
4
4
 
5
5
  Create and verify consumer driven contracts for messages.
6
6
 
7
- This project is still under development and is not ready for production use.
7
+
8
8
 
9
9
  ## Installation
10
10
 
11
11
  Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
+ gem 'pact'
14
15
  gem 'pact-message'
15
16
  ```
16
17
 
@@ -20,11 +21,76 @@ And then execute:
20
21
 
21
22
  Or install it yourself as:
22
23
 
24
+ $ gem install pact
23
25
  $ gem install pact-message
24
26
 
25
27
  ## Usage
26
28
 
29
+ The key to using Message Pact is to completely separate the business logic that creates the message from the transmission protocol (eg. Kafka, Websockets, Lambda). This allows you to write a contract for the message contents, no matter how it is communicated.
30
+
31
+ ### Consumer
32
+
33
+ Not finished yet as nobody has asked for it. Ping @Beth Skurrie on slack.pact.io if you'd like use this.
34
+
35
+ ### Provider
36
+
37
+ Also called a "producer". Message pact verification follows all the same principles as HTTP pact verification, except that instead of verifying that a provider can make the expected HTTP response, we are verifying that the provider can create the expected message. Please read the HTTP Pact [verification](https://github.com/pact-foundation/pact-ruby/wiki/Verifying-pacts) documentation. The only difference is in the configuration block. Use `message_provider` instead of `service_provider`, and configure a `builder` block that takes a `|description|` argument, instead of a Rack `app` block.
38
+
39
+ Make sure you've required 'pact/message' as well as 'pact'.
40
+
41
+ ```ruby
42
+ require 'pact'
43
+ require 'pact/message'
44
+
45
+ Pact.message_provider "MyMessageProvider" do
46
+ honours_pact_with "MyMessageConsumer" do
47
+ pact_uri "/path/or/url/to/your/pact", {
48
+ username: "optional username",
49
+ password: "optional password",
50
+ token: "optional token"
51
+ }
52
+ end
53
+
54
+ # or
55
+
56
+ honours_pacts_from_pact_broker do
57
+ # See docs at https://github.com/pact-foundation/pact-ruby/wiki/Verifying-pacts
58
+ end
59
+
60
+ builder do |message_description|
61
+ #... code that accepts a message description and returns
62
+ # a message hash that should match what is expected in the pact
63
+ do
64
+ end
65
+
66
+ ```
67
+
68
+ How you map between the message description and the code that creates the message is up to you. The easiest way is something like this:
69
+
70
+ ```ruby
71
+ class MyMessageProvider
72
+ def create_hello_message
73
+ {
74
+ text: "Hello world"
75
+ }
76
+ end
77
+ end
78
+
79
+ CONFIG = {
80
+ "a hello message" => lambda { MyMessageProvider.new.create_hello_message }
81
+ }
82
+
83
+ Pact.message_provider "SomeProvider" do
84
+ builder do |description|
85
+ CONFIG[description].call
86
+ do
87
+ end
88
+
89
+ ```
90
+
91
+ #### Provider states
27
92
 
93
+ Provider states work the same way for Message Pact as they do for HTTP Pact. Please read the [provider state](https://github.com/pact-foundation/pact-ruby#using-provider-states) docs in the HTTP Pact project.
28
94
 
29
95
  ## Development
30
96
 
@@ -13,7 +13,7 @@ module Pact
13
13
  include Pact::ActiveSupportSupport
14
14
  include Pact::SymbolizeKeys
15
15
 
16
- attr_accessor :description, :contents, :provider_state, :provider_states, :metadata
16
+ attr_accessor :description, :contents, :provider_state, :provider_states, :metadata, :_id, :index
17
17
 
18
18
  def initialize attributes = {}
19
19
  @description = attributes[:description]
@@ -21,6 +21,8 @@ module Pact
21
21
  @provider_states = attributes[:provider_states] || []
22
22
  @contents = attributes[:contents]
23
23
  @metadata = attributes[:metadata]
24
+ @_id = attributes[:_id]
25
+ @index = attributes[:index]
24
26
  end
25
27
 
26
28
  def self.from_hash hash, options = {}
@@ -32,11 +34,12 @@ module Pact
32
34
  contents_hash = Pact::MatchingRules.merge(hash['contents'], contents_matching_rules, opts)
33
35
  contents = Pact::ConsumerContract::Message::Contents.from_hash(contents_hash)
34
36
  metadata = hash['metaData'] || hash['metadata']
35
- provider_state = hash['providerStates'] && hash['providerStates'].first && hash['providerStates'].first['name']
36
- provider_states = parse_provider_states(hash['providerStates'])
37
+
38
+ provider_state_name = parse_provider_state_name(hash['providerState'], hash['providerStates'])
39
+ provider_states = parse_provider_states(provider_state_name, hash['providerStates'])
37
40
  new(symbolize_keys(hash).merge(
38
41
  contents: contents,
39
- provider_state: provider_state,
42
+ provider_state: provider_state_name,
40
43
  provider_states: provider_states,
41
44
  metadata: metadata))
42
45
  end
@@ -61,7 +64,8 @@ module Pact
61
64
  providerStates: [{
62
65
  name: provider_state,
63
66
  params: {}
64
- }]
67
+ }],
68
+ metadata: metadata
65
69
  }
66
70
  )
67
71
  end
@@ -120,9 +124,19 @@ module Pact
120
124
 
121
125
  private
122
126
 
123
- def self.parse_provider_states provider_states
124
- (provider_states || []).collect do | provider_state_hash |
125
- Pact::ProviderState.new(provider_state_hash['name'], provider_state_hash['params'])
127
+ def self.parse_provider_state_name provider_state, provider_states
128
+ (provider_states && provider_states.first && provider_states.first['name']) || provider_state
129
+ end
130
+
131
+ def self.parse_provider_states provider_state_name, provider_states
132
+ if provider_states && provider_states.any?
133
+ provider_states.collect do | provider_state_hash |
134
+ Pact::ProviderState.new(provider_state_hash['name'], provider_state_hash['params'])
135
+ end
136
+ elsif provider_state_name
137
+ [Pact::ProviderState.new(provider_state_name, {})]
138
+ else
139
+ []
126
140
  end
127
141
  end
128
142
  end
@@ -11,7 +11,9 @@ module Pact
11
11
  def call(hash)
12
12
  hash = symbolize_keys(hash)
13
13
  options = { pact_specification_version: pact_specification_version(hash) }
14
- interactions = hash[:messages].collect { |hash| Pact::ConsumerContract::Message.from_hash(hash, options)}
14
+ interactions = hash[:messages].each_with_index.collect do |hash, index|
15
+ Pact::ConsumerContract::Message.from_hash({ index: index }.merge(hash), options)
16
+ end
15
17
  ConsumerContract.new(
16
18
  :consumer => ServiceConsumer.from_hash(hash[:consumer]),
17
19
  :provider => ServiceProvider.from_hash(hash[:provider]),
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Message
3
- VERSION = "0.6.0"
3
+ VERSION = "0.7.0"
4
4
  end
5
5
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency "pact-mock_service", "~> 3.1"
37
37
  spec.add_runtime_dependency "thor", "~> 0.20"
38
38
 
39
- spec.add_development_dependency "bundler", "~> 1.15"
39
+ spec.add_development_dependency "bundler", "~> 1.17.3"
40
40
  spec.add_development_dependency "rake", "~> 10.0"
41
41
  spec.add_development_dependency "rspec", "~> 3.0"
42
42
  spec.add_development_dependency "pry-byebug"
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env bash
2
+
3
+ export IMAGE=pact_message_ruby_bundle_base
4
+
5
+ function docker_build_bundle_base() {
6
+ docker build . -f Dockerfile-bundle-base -t $IMAGE
7
+ }
8
+
9
+ function bundle_update_on_docker() {
10
+ rm -rf tmp/Gemfile.lock
11
+ docker run --rm -v ${PWD}/tmp:/tmp/bundle_update $IMAGE:latest sh -c "bundle update && cp Gemfile.lock /tmp/bundle_update"
12
+ mv tmp/Gemfile.lock .
13
+ }
14
+
15
+ function on_docker() {
16
+ docker run --rm -v ${PWD}:/app $IMAGE:latest sh -c "$@"
17
+ }
18
+
19
+ gem_version() {
20
+ on_docker "bundle exec ruby -e \"require 'bump'; puts Bump::Bump.current\""
21
+ }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ gem_version() {
4
+ on_docker "bundle exec ruby -e \"require 'bump'; puts Bump::Bump.current\""
5
+ }
@@ -1,13 +1,26 @@
1
- #!/bin/bash
1
+ #!/bin/sh
2
2
  set -e
3
3
 
4
+ source script/docker-functions
5
+
4
6
  # avoid accidentally double incrementing when previous run fails
5
7
  git reset HEAD CHANGELOG.md lib/pact/message/version.rb
6
8
  git checkout -- lib/pact/message/version.rb
7
9
  git checkout -- CHANGELOG.md
8
- bundle exec bump ${1:-minor} --no-commit
9
- bundle exec rake generate_changelog
10
+
11
+ docker_build_bundle_base
12
+
13
+ script/release/bump-version.sh $1
14
+ script/release/generate-changelog.sh
15
+
10
16
  git add CHANGELOG.md lib/pact/message/version.rb
11
- git commit -m "chore(release): version $(ruby -r ./lib/pact/message/version.rb -e "puts Pact::Message::VERSION")"
12
- # bundle exec rake tag_for_release # TODO move release to travis
13
- bundle exec rake release
17
+ git commit -m "chore(release): version ${VERSION}
18
+
19
+ [ci-skip]"
20
+
21
+ VERSION=$(gem_version)
22
+ TAG="v${VERSION}"
23
+ git tag -a "${TAG}" -m "Releasing version ${TAG}"
24
+ git push origin "${TAG}"
25
+ git push origin master
26
+ echo "Releasing from https://travis-ci.org/pact-foundation/pact-message-ruby/builds"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env sh
2
+
3
+ source script/docker-functions
4
+
5
+ on_docker "bundle exec bump ${1:-minor} --no-commit"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+
3
+ set -e
4
+
5
+ source script/docker-functions
6
+ on_docker "bundle exec rake generate_changelog"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-message
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Beth Skurrie
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2020-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pact-support
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.15'
61
+ version: 1.17.3
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.15'
68
+ version: 1.17.3
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -152,6 +152,7 @@ files:
152
152
  - CHANGELOG.md
153
153
  - CONTRIBUTING.md
154
154
  - DEVELOPER_DOCUMENTATION.md
155
+ - Dockerfile-bundle-base
155
156
  - Gemfile
156
157
  - LICENSE.txt
157
158
  - QUESTIONS.md
@@ -181,7 +182,11 @@ files:
181
182
  - lib/pact/message/consumer_contract_parser.rb
182
183
  - lib/pact/message/version.rb
183
184
  - pact-message.gemspec
185
+ - script/docker-functions
186
+ - script/functions
184
187
  - script/release.sh
188
+ - script/release/bump-version.sh
189
+ - script/release/generate-changelog.sh
185
190
  - script/update-pact.sh
186
191
  - tasks/release.rake
187
192
  homepage: http://pact.io
@@ -205,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
210
  version: '0'
206
211
  requirements: []
207
212
  rubyforge_project:
208
- rubygems_version: 2.6.11
213
+ rubygems_version: 2.7.7
209
214
  signing_key:
210
215
  specification_version: 4
211
216
  summary: Consumer contract library for messages