workable-pact-message 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +12 -0
- data/CHANGELOG.md +88 -0
- data/CONTRIBUTING.md +1 -0
- data/DEVELOPER_DOCUMENTATION.md +33 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/QUESTIONS.md +3 -0
- data/README.md +41 -0
- data/Rakefile +8 -0
- data/bin/pact-message +3 -0
- data/bin/setup +8 -0
- data/lib/pact/consumer_contract/message.rb +142 -0
- data/lib/pact/consumer_contract/message/contents.rb +49 -0
- data/lib/pact/message.rb +4 -0
- data/lib/pact/message/cli.rb +34 -0
- data/lib/pact/message/consumer/configuration.rb +4 -0
- data/lib/pact/message/consumer/configuration/configuration_extensions.rb +19 -0
- data/lib/pact/message/consumer/configuration/message_builder.rb +67 -0
- data/lib/pact/message/consumer/configuration/message_consumer.rb +38 -0
- data/lib/pact/message/consumer/configuration/message_provider.rb +39 -0
- data/lib/pact/message/consumer/consumer_contract_builder.rb +59 -0
- data/lib/pact/message/consumer/consumer_contract_builders.rb +12 -0
- data/lib/pact/message/consumer/consumer_contract_decorator.rb +25 -0
- data/lib/pact/message/consumer/dsl.rb +13 -0
- data/lib/pact/message/consumer/interaction_builder.rb +38 -0
- data/lib/pact/message/consumer/interaction_decorator.rb +56 -0
- data/lib/pact/message/consumer/rspec.rb +26 -0
- data/lib/pact/message/consumer/spec_hooks.rb +13 -0
- data/lib/pact/message/consumer/update_pact.rb +43 -0
- data/lib/pact/message/consumer_contract_parser.rb +38 -0
- data/lib/pact/message/version.rb +5 -0
- data/pact-message.gemspec +45 -0
- data/script/release.sh +13 -0
- data/script/update-pact.sh +15 -0
- data/tasks/release.rake +15 -0
- metadata +209 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
module Pact
|
2
|
+
module Message
|
3
|
+
module Consumer
|
4
|
+
class SpecHooks
|
5
|
+
def after_each example_description
|
6
|
+
Pact.configuration.message_provider_verifications.each do | message_provider_verification |
|
7
|
+
message_provider_verification.call example_description
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'pact/consumer_contract/consumer_contract_writer'
|
2
|
+
require 'pact/message/consumer/consumer_contract_decorator'
|
3
|
+
|
4
|
+
module Pact
|
5
|
+
module Message
|
6
|
+
module Consumer
|
7
|
+
class UpdatePact
|
8
|
+
|
9
|
+
def initialize message, pact_dir, consumer_name, provider_name, pact_specification_version
|
10
|
+
@pact_dir = pact_dir
|
11
|
+
@message = message
|
12
|
+
@consumer_name = consumer_name
|
13
|
+
@provider_name = provider_name
|
14
|
+
@pact_specification_version = pact_specification_version
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.call(message, pact_dir, consumer_name, provider_name, pact_specification_version)
|
18
|
+
new(message, pact_dir, consumer_name, provider_name, pact_specification_version).call
|
19
|
+
end
|
20
|
+
|
21
|
+
def call
|
22
|
+
details = {
|
23
|
+
consumer: {name: consumer_name},
|
24
|
+
provider: {name: provider_name},
|
25
|
+
interactions: [message],
|
26
|
+
pactfile_write_mode: :update,
|
27
|
+
pact_dir: pact_dir,
|
28
|
+
pact_specification_version: pact_specification_version,
|
29
|
+
error_stream: StringIO.new,
|
30
|
+
output_stream: StringIO.new,
|
31
|
+
consumer_contract_decorator_class: Pact::Message::Consumer::ConsumerContractDecorator
|
32
|
+
}
|
33
|
+
writer = Pact::ConsumerContractWriter.new(details, Logger.new(StringIO.new))
|
34
|
+
writer.write
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :message, :pact_dir, :consumer_name, :provider_name, :pact_specification_version
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'pact/consumer_contract'
|
2
|
+
require 'pact/consumer_contract/message'
|
3
|
+
require 'pact/consumer_contract/message/contents'
|
4
|
+
require 'pact/consumer_contract/provider_state'
|
5
|
+
|
6
|
+
module Pact
|
7
|
+
module Message
|
8
|
+
class ConsumerContractParser
|
9
|
+
include SymbolizeKeys
|
10
|
+
|
11
|
+
def call(hash)
|
12
|
+
hash = symbolize_keys(hash)
|
13
|
+
options = { pact_specification_version: pact_specification_version(hash) }
|
14
|
+
interactions = hash[:messages].collect { |hash| Pact::ConsumerContract::Message.from_hash(hash, options)}
|
15
|
+
ConsumerContract.new(
|
16
|
+
:consumer => ServiceConsumer.from_hash(hash[:consumer]),
|
17
|
+
:provider => ServiceProvider.from_hash(hash[:provider]),
|
18
|
+
:interactions => interactions
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def can_parse?(hash)
|
23
|
+
hash.key?('messages') || hash.key?(:messages)
|
24
|
+
end
|
25
|
+
|
26
|
+
def pact_specification_version hash
|
27
|
+
# TODO handle all 3 ways of defining this...
|
28
|
+
# metadata.pactSpecificationVersion
|
29
|
+
maybe_pact_specification_version_1 = hash[:metadata] && hash[:metadata]['pactSpecification'] && hash[:metadata]['pactSpecification']['version']
|
30
|
+
maybe_pact_specification_version_2 = hash[:metadata] && hash[:metadata]['pactSpecificationVersion']
|
31
|
+
pact_specification_version = maybe_pact_specification_version_1 || maybe_pact_specification_version_2
|
32
|
+
pact_specification_version ? Pact::SpecificationVersion.new(pact_specification_version) : Pact::SpecificationVersion::NIL_VERSION
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Pact::ConsumerContract.add_parser(Pact::Message::ConsumerContractParser.new)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "pact/message/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "workable-pact-message"
|
8
|
+
spec.version = Pact::Message::VERSION
|
9
|
+
spec.authors = ["Angelos Karagkiozidis"]
|
10
|
+
spec.email = ["angelos@workable.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Consumer contract library for messages}
|
13
|
+
spec.homepage = "http://pact.io"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
spec.bindir = "bin"
|
29
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_runtime_dependency "pact-support", "~> 1.8"
|
33
|
+
# pact-mock_service dependencies are Pact::ConsumerContractDecorator
|
34
|
+
# and Pact::ConsumerContractWriter. Potentially we should extract
|
35
|
+
# or duplicate these classes to remove the pact-mock_service dependency.
|
36
|
+
spec.add_runtime_dependency "pact-mock_service", "~> 3.1"
|
37
|
+
spec.add_runtime_dependency "thor", "~> 0.19"
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
spec.add_development_dependency "pry-byebug"
|
43
|
+
spec.add_development_dependency 'conventional-changelog', '~>1.2'
|
44
|
+
spec.add_development_dependency 'bump', '~> 0.5'
|
45
|
+
end
|
data/script/release.sh
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
# avoid accidentally double incrementing when previous run fails
|
5
|
+
git reset HEAD CHANGELOG.md lib/pact/message/version.rb
|
6
|
+
git checkout -- lib/pact/message/version.rb
|
7
|
+
git checkout -- CHANGELOG.md
|
8
|
+
bundle exec bump ${1:-minor} --no-commit
|
9
|
+
bundle exec rake generate_changelog
|
10
|
+
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
|
@@ -0,0 +1,15 @@
|
|
1
|
+
bundle exec bin/pact-message update '{
|
2
|
+
"description": "a test mesage",
|
3
|
+
"providerStates": [
|
4
|
+
{
|
5
|
+
"name": "an alligator named Mary exists"
|
6
|
+
}
|
7
|
+
],
|
8
|
+
"contents": {
|
9
|
+
"name": {
|
10
|
+
"contents": "Mary",
|
11
|
+
"json_class": "Pact::SomethingLike"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
' --consumer Foo --provider Bar --pact-dir ./tmp --pact-specification-version 3.0.0
|
data/tasks/release.rake
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
desc 'Generate change log'
|
2
|
+
task :generate_changelog do
|
3
|
+
require 'conventional_changelog'
|
4
|
+
require 'pact/message/version'
|
5
|
+
ConventionalChangelog::Generator.new.generate! version: "v#{Pact::Message::VERSION}"
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Tag for release'
|
9
|
+
task :tag_for_release do | t, args |
|
10
|
+
require 'pact/message/version'
|
11
|
+
version = Pact::Message::VERSION
|
12
|
+
command = "git tag -a v#{version} -m \"chore(release): version #{version}\" && git push origin v#{version}"
|
13
|
+
puts command
|
14
|
+
puts `#{command}`
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,209 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: workable-pact-message
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Angelos Karagkiozidis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pact-support
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pact-mock_service
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.19'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.19'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.15'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: conventional-changelog
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.2'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: bump
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.5'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.5'
|
139
|
+
description:
|
140
|
+
email:
|
141
|
+
- angelos@workable.com
|
142
|
+
executables:
|
143
|
+
- pact-message
|
144
|
+
- setup
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files: []
|
147
|
+
files:
|
148
|
+
- ".gitignore"
|
149
|
+
- ".rspec"
|
150
|
+
- ".travis.yml"
|
151
|
+
- CHANGELOG.md
|
152
|
+
- CONTRIBUTING.md
|
153
|
+
- DEVELOPER_DOCUMENTATION.md
|
154
|
+
- Gemfile
|
155
|
+
- LICENSE.txt
|
156
|
+
- QUESTIONS.md
|
157
|
+
- README.md
|
158
|
+
- Rakefile
|
159
|
+
- bin/pact-message
|
160
|
+
- bin/setup
|
161
|
+
- lib/pact/consumer_contract/message.rb
|
162
|
+
- lib/pact/consumer_contract/message/contents.rb
|
163
|
+
- lib/pact/message.rb
|
164
|
+
- lib/pact/message/cli.rb
|
165
|
+
- lib/pact/message/consumer/configuration.rb
|
166
|
+
- lib/pact/message/consumer/configuration/configuration_extensions.rb
|
167
|
+
- lib/pact/message/consumer/configuration/message_builder.rb
|
168
|
+
- lib/pact/message/consumer/configuration/message_consumer.rb
|
169
|
+
- lib/pact/message/consumer/configuration/message_provider.rb
|
170
|
+
- lib/pact/message/consumer/consumer_contract_builder.rb
|
171
|
+
- lib/pact/message/consumer/consumer_contract_builders.rb
|
172
|
+
- lib/pact/message/consumer/consumer_contract_decorator.rb
|
173
|
+
- lib/pact/message/consumer/dsl.rb
|
174
|
+
- lib/pact/message/consumer/interaction_builder.rb
|
175
|
+
- lib/pact/message/consumer/interaction_decorator.rb
|
176
|
+
- lib/pact/message/consumer/rspec.rb
|
177
|
+
- lib/pact/message/consumer/spec_hooks.rb
|
178
|
+
- lib/pact/message/consumer/update_pact.rb
|
179
|
+
- lib/pact/message/consumer_contract_parser.rb
|
180
|
+
- lib/pact/message/version.rb
|
181
|
+
- pact-message.gemspec
|
182
|
+
- script/release.sh
|
183
|
+
- script/update-pact.sh
|
184
|
+
- tasks/release.rake
|
185
|
+
homepage: http://pact.io
|
186
|
+
licenses:
|
187
|
+
- MIT
|
188
|
+
metadata:
|
189
|
+
allowed_push_host: https://rubygems.org
|
190
|
+
post_install_message:
|
191
|
+
rdoc_options: []
|
192
|
+
require_paths:
|
193
|
+
- lib
|
194
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
+
requirements:
|
196
|
+
- - ">="
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
version: '0'
|
204
|
+
requirements: []
|
205
|
+
rubygems_version: 3.0.6
|
206
|
+
signing_key:
|
207
|
+
specification_version: 4
|
208
|
+
summary: Consumer contract library for messages
|
209
|
+
test_files: []
|