pact-message 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2db11376814a1b7522831243a0f50d51aa70837f
4
- data.tar.gz: dfe86bc1cdf37c3a7a0db45f65e72befa0f0bc2a
3
+ metadata.gz: f8d37a134b83c10962b37435bf425ce69c8751a6
4
+ data.tar.gz: e1fce249bfee4a95eee7d40dd1f81048f2c68ab9
5
5
  SHA512:
6
- metadata.gz: d1dd0d8cdd38e3030a7625ad5e5d129f970e99e29f1156915aa01aa9bd7d76af4322665b23b27cec9c33cf22b0ffa21d0d5a8dd902e342583163e953745ffddf
7
- data.tar.gz: 34f4a05ce4ae291b77ae456cda1a661d1cb28a8d32afeca9596e083d96679c12d9dbac8fd1aeb7535047619ed07c17fe4e079a96c00c00edbfd0ec0c38d64870
6
+ metadata.gz: 382faf25a819b3589a4ffbd2e259e8fcc09341400738d1dea3e03d757d803e02ec83d4ad1ff114fe2f209a09c49734d56c09e633cb1626f9c41ef3ce37ba9496
7
+ data.tar.gz: 2fe5306302cacaad96d5f257bcfe25f02b018df33dfef4b91fbd23852a44181df5fcb52645471004505e08d84b5485ee90f421b0509d8ec64021d53be36cfb4b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ <a name="v0.5.0"></a>
2
+ ### v0.5.0 (2018-10-04)
3
+
4
+
5
+ #### Features
6
+
7
+ * **pact specification v3**
8
+ * add support for multiple provider states and params ([b2c1cc7](/../../commit/b2c1cc7))
9
+
10
+
1
11
  <a name="v0.4.5"></a>
2
12
  ### v0.4.5 (2018-07-07)
3
13
 
@@ -13,11 +13,12 @@ module Pact
13
13
  include Pact::ActiveSupportSupport
14
14
  include Pact::SymbolizeKeys
15
15
 
16
- attr_accessor :description, :contents, :provider_state, :metadata
16
+ attr_accessor :description, :contents, :provider_state, :provider_states, :metadata
17
17
 
18
18
  def initialize attributes = {}
19
19
  @description = attributes[:description]
20
20
  @provider_state = attributes[:provider_state] || attributes[:providerState]
21
+ @provider_states = attributes[:provider_states] || []
21
22
  @contents = attributes[:contents]
22
23
  @metadata = attributes[:metadata]
23
24
  end
@@ -32,9 +33,12 @@ module Pact
32
33
  contents = Pact::ConsumerContract::Message::Contents.from_hash(contents_hash)
33
34
  metadata = hash['metaData'] || hash['metadata']
34
35
  provider_state = hash['providerStates'] && hash['providerStates'].first && hash['providerStates'].first['name']
35
- warn_if_multiple_provider_states(provider_state, hash)
36
- warn_if_params_used_in_provider_states(hash)
37
- new(symbolize_keys(hash).merge(contents: contents, provider_state: provider_state, metadata: metadata))
36
+ provider_states = parse_provider_states(hash['providerStates'])
37
+ new(symbolize_keys(hash).merge(
38
+ contents: contents,
39
+ provider_state: provider_state,
40
+ provider_states: provider_states,
41
+ metadata: metadata))
38
42
  end
39
43
 
40
44
  def to_hash
@@ -116,19 +120,9 @@ module Pact
116
120
 
117
121
  private
118
122
 
119
- def self.warn_if_multiple_provider_states(provider_state, hash)
120
- if hash['providerStates'] && hash['providerStates'].size > 1
121
- ignored_list = hash['providerStates'].collect{ |provider_state| "\"#{provider_state['name']}\"" }[1..-1].join(", ")
122
- 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}")
123
- end
124
- end
125
-
126
- def self.warn_if_params_used_in_provider_states(hash)
127
- return unless hash['providerStates']
128
- provider_states_with_params = hash['providerStates'].select{ | provider_state | provider_state.fetch('params', {}).any? }
129
- if provider_states_with_params.any?
130
- ignored_list = provider_states_with_params.collect{ |provider_state| "\"#{provider_state['name']}\"" }.join(", ")
131
- Pact.configuration.error_stream.puts("WARN: Ignoring params for the following provider states as params support is not yet implemented: #{ignored_list}")
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'])
132
126
  end
133
127
  end
134
128
  end
@@ -14,7 +14,7 @@ module Pact
14
14
 
15
15
  def as_json options = {}
16
16
  hash = { :description => message.description }
17
- hash[:providerStates] = provider_states if message.provider_state
17
+ hash[:providerStates] = provider_states
18
18
  hash[:contents] = extract_contents
19
19
  hash[:matchingRules] = extract_matching_rules
20
20
  hash[:metaData] = message.metadata || {}
@@ -38,7 +38,7 @@ module Pact
38
38
  end
39
39
 
40
40
  def provider_states
41
- [{ name: message.provider_state }]
41
+ message.provider_states.collect(&:as_json)
42
42
  end
43
43
 
44
44
  def extract_matching_rules
@@ -1,6 +1,7 @@
1
1
  require 'pact/consumer_contract'
2
2
  require 'pact/consumer_contract/message'
3
3
  require 'pact/consumer_contract/message/contents'
4
+ require 'pact/consumer_contract/provider_state'
4
5
 
5
6
  module Pact
6
7
  module Message
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Message
3
- VERSION = "0.4.5"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
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.6"
32
+ spec.add_runtime_dependency "pact-support", "~> 1.8"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-message
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.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: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pact-support
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.8'
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.6'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pact-mock_service
29
29
  requirement: !ruby/object:Gem::Requirement