pact-message 0.3.0 → 0.4.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/pact/consumer_contract/message/content.rb +4 -0
- data/lib/pact/consumer_contract/message.rb +22 -1
- data/lib/pact/message/cli.rb +1 -1
- data/lib/pact/message/consumer/interaction_decorator.rb +26 -7
- data/lib/pact/message/version.rb +1 -1
- data/pact-message.gemspec +1 -1
- data/script/update-pact.sh +10 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb08c5946bc8332b709fbe150f0a1bac91dd48ad
|
4
|
+
data.tar.gz: 4fe6956ee6a15e093e74f2970b953ab4cedaa671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f2b71dea1efceef4f09cd8c89e12ca9f86e18fb4b1ae43dfe93b11cb43a447055fc732ff8baf17a1a01962748f6ebcb1108b3327c4e0d7caffbc5d220eedde9
|
7
|
+
data.tar.gz: 8d141b680689853b612c6052bb2821d711f5f1b6b5fdde4ac6426427d18dd632f8c55121c7644aec074cb7ffb82657b8ddcff491c6e2d8bd87abb785478dfbdd
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
<a name="v0.4.0"></a>
|
2
|
+
### v0.4.0 (2018-04-03)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* add *partial* support for reading/writing array of provider states as specified in v3 spec ([e9ec6c3](/../../commit/e9ec6c3))
|
8
|
+
|
9
|
+
|
1
10
|
<a name="v0.3.0"></a>
|
2
11
|
### v0.3.0 (2018-04-03)
|
3
12
|
|
@@ -28,7 +28,10 @@ module Pact
|
|
28
28
|
end
|
29
29
|
content_hash = Pact::MatchingRules.merge(hash['content'], hash['content']['matchingRules'], opts)
|
30
30
|
content = Pact::ConsumerContract::Message::Content.from_hash(content_hash)
|
31
|
-
|
31
|
+
provider_state = hash['providerStates'] && hash['providerStates'].first && hash['providerStates'].first['name']
|
32
|
+
warn_if_multiple_provider_states(provider_state, hash)
|
33
|
+
warn_if_params_used_in_provider_states(hash)
|
34
|
+
new(symbolize_keys(hash).merge(content: content, provider_state: provider_state))
|
32
35
|
end
|
33
36
|
|
34
37
|
def to_hash
|
@@ -114,6 +117,24 @@ module Pact
|
|
114
117
|
def to_s
|
115
118
|
to_hash.to_s
|
116
119
|
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def self.warn_if_multiple_provider_states(provider_state, hash)
|
124
|
+
if hash['providerStates'] && hash['providerStates'].size > 1
|
125
|
+
ignored_list = hash['providerStates'].collect{ |provider_state| "\"#{provider_state['name']}\"" }[1..-1].join(", ")
|
126
|
+
Pact.configuration.error_stream.puts("WARN: Using only the first provider state, \"#{provider_state}\", as support for multiple provider states is not yet implemented. Ignoring provider states: #{ignored_list}")
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.warn_if_params_used_in_provider_states(hash)
|
131
|
+
return unless hash['providerStates']
|
132
|
+
provider_states_with_params = hash['providerStates'].select{ | provider_state | provider_state.fetch('params', {}).any? }
|
133
|
+
if provider_states_with_params.any?
|
134
|
+
ignored_list = provider_states_with_params.collect{ |provider_state| "\"#{provider_state['name']}\"" }.join(", ")
|
135
|
+
Pact.configuration.error_stream.puts("WARN: Ignoring params for the following provider states as params support is not yet implemented: #{ignored_list}")
|
136
|
+
end
|
137
|
+
end
|
117
138
|
end
|
118
139
|
end
|
119
140
|
end
|
data/lib/pact/message/cli.rb
CHANGED
@@ -14,7 +14,7 @@ module Pact
|
|
14
14
|
require 'pact/message'
|
15
15
|
require 'pact/message/consumer/update_pact'
|
16
16
|
pact_specification_version = Pact::SpecificationVersion.new(options.pact_specification_version)
|
17
|
-
message = Pact::Message.from_hash(JSON.
|
17
|
+
message = Pact::Message.from_hash(JSON.load(message), { pact_specification_version: pact_specification_version })
|
18
18
|
Pact::Message::Consumer::UpdatePact.call(message, options.pact_dir, options.consumer, options.provider, options.pact_specification_version)
|
19
19
|
end
|
20
20
|
|
@@ -7,15 +7,16 @@ module Pact
|
|
7
7
|
|
8
8
|
include ActiveSupportSupport
|
9
9
|
|
10
|
-
def initialize
|
11
|
-
@
|
10
|
+
def initialize message, decorator_options = {}
|
11
|
+
@message = message
|
12
12
|
@decorator_options = decorator_options
|
13
13
|
end
|
14
14
|
|
15
15
|
def as_json options = {}
|
16
|
-
hash = { :description =>
|
17
|
-
hash[:
|
18
|
-
hash[:content] =
|
16
|
+
hash = { :description => message.description }
|
17
|
+
hash[:providerStates] = provider_states if message.provider_state
|
18
|
+
hash[:content] = extract_content
|
19
|
+
hash[:matchingRules] = extract_matching_rules
|
19
20
|
fix_all_the_things hash
|
20
21
|
end
|
21
22
|
|
@@ -25,10 +26,28 @@ module Pact
|
|
25
26
|
|
26
27
|
private
|
27
28
|
|
28
|
-
attr_reader :
|
29
|
+
attr_reader :message
|
29
30
|
|
30
31
|
def decorate_content
|
31
|
-
|
32
|
+
message.content.as_json
|
33
|
+
end
|
34
|
+
|
35
|
+
def extract_content
|
36
|
+
Pact::Reification.from_term(message.content.content)
|
37
|
+
end
|
38
|
+
|
39
|
+
def provider_states
|
40
|
+
[{ name: message.provider_state }]
|
41
|
+
end
|
42
|
+
|
43
|
+
def extract_matching_rules
|
44
|
+
{
|
45
|
+
body: Pact::MatchingRules.extract(message.content.content, pact_specification_version: pact_specification_version)
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def pact_specification_version
|
50
|
+
Pact::SpecificationVersion.new(@decorator_options[:pact_specification_version])
|
32
51
|
end
|
33
52
|
end
|
34
53
|
end
|
data/lib/pact/message/version.rb
CHANGED
data/pact-message.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
|
-
spec.add_runtime_dependency "pact-support", "~> 1.
|
32
|
+
spec.add_runtime_dependency "pact-support", "~> 1.6"
|
33
33
|
# pact-mock_service dependencies are Pact::ConsumerContractDecorator
|
34
34
|
# and Pact::ConsumerContractWriter. Potentially we should extract
|
35
35
|
# or duplicate these classes to remove the pact-mock_service dependency.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-message
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Beth Skurrie
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.6'
|
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
|
-
version: '1.
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pact-mock_service
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- lib/pact/message/version.rb
|
183
183
|
- pact-message.gemspec
|
184
184
|
- script/release.sh
|
185
|
+
- script/update-pact.sh
|
185
186
|
- tasks/release.rake
|
186
187
|
homepage: http://pact.io
|
187
188
|
licenses:
|