pact-message 0.4.1 → 0.4.3
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 +16 -0
- data/lib/pact/consumer_contract/message.rb +11 -11
- data/lib/pact/consumer_contract/message/contents.rb +49 -0
- data/lib/pact/message/cli.rb +5 -0
- data/lib/pact/message/consumer/consumer_contract_builder.rb +2 -2
- data/lib/pact/message/consumer/interaction_builder.rb +1 -1
- data/lib/pact/message/consumer/interaction_decorator.rb +6 -6
- data/lib/pact/message/consumer_contract_parser.rb +1 -1
- data/lib/pact/message/version.rb +1 -1
- data/script/update-pact.sh +1 -1
- metadata +3 -3
- data/lib/pact/consumer_contract/message/content.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c298a5c26b7e2525401462a2e295bc3b8e7e176c
|
4
|
+
data.tar.gz: a442288d24e1a72fdb9a55add17e14649007e08e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6c93d26c1f87d02abda79a409f3bfc782864a54bc837599df28a0030dcdd41639dd9877df22b4e59ef12154698d94008534ac0abcc940314e8ef9d4a0ce7482
|
7
|
+
data.tar.gz: b88265f0b0dbf1f0974eb17ee55ef2edad26c6c79646cf7d626460a5a7ff118d9c522ba59215a6d6a437503b6feb7273c48e958e5ec1d9fb7b25f51d9e6f1abc
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
<a name="v0.4.3"></a>
|
2
|
+
### v0.4.3 (2018-05-06)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* **version**
|
8
|
+
* add version command to CLI, fixes #10 ([f928248](/../../commit/f928248))
|
9
|
+
|
10
|
+
|
11
|
+
#### Bug Fixes
|
12
|
+
|
13
|
+
* **content**
|
14
|
+
* rename message content -> contents. fixes #9 ([0908962](/../../commit/0908962))
|
15
|
+
|
16
|
+
|
1
17
|
<a name="v0.4.1"></a>
|
2
18
|
### v0.4.1 (2018-04-05)
|
3
19
|
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require 'pact/consumer_contract/message/
|
1
|
+
require 'pact/consumer_contract/message/contents'
|
2
2
|
require 'pact/symbolize_keys'
|
3
3
|
require 'pact/shared/active_support_support'
|
4
4
|
require 'pact/matching_rules'
|
5
5
|
require 'pact/errors'
|
6
6
|
require 'pact/consumer/request'
|
7
7
|
require 'pact/consumer_contract/response'
|
8
|
-
require 'pact/consumer_contract/message/
|
8
|
+
require 'pact/consumer_contract/message/contents'
|
9
9
|
|
10
10
|
module Pact
|
11
11
|
class ConsumerContract
|
@@ -13,12 +13,12 @@ module Pact
|
|
13
13
|
include Pact::ActiveSupportSupport
|
14
14
|
include Pact::SymbolizeKeys
|
15
15
|
|
16
|
-
attr_accessor :description, :
|
16
|
+
attr_accessor :description, :contents, :provider_state, :metadata
|
17
17
|
|
18
18
|
def initialize attributes = {}
|
19
19
|
@description = attributes[:description]
|
20
20
|
@provider_state = attributes[:provider_state] || attributes[:providerState]
|
21
|
-
@
|
21
|
+
@contents = attributes[:contents]
|
22
22
|
@metadata = attributes[:metadata]
|
23
23
|
end
|
24
24
|
|
@@ -27,21 +27,21 @@ module Pact
|
|
27
27
|
unless opts[:pact_specification_version]
|
28
28
|
opts[:pact_specification_version] = Pact::SpecificationVersion::NIL_VERSION
|
29
29
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
contents_matching_rules = hash['matchingRules'] && hash['matchingRules']['body']
|
31
|
+
contents_hash = Pact::MatchingRules.merge(hash['contents'], contents_matching_rules, opts)
|
32
|
+
contents = Pact::ConsumerContract::Message::Contents.from_hash(contents_hash)
|
33
33
|
metadata = hash['metaData']
|
34
34
|
provider_state = hash['providerStates'] && hash['providerStates'].first && hash['providerStates'].first['name']
|
35
35
|
warn_if_multiple_provider_states(provider_state, hash)
|
36
36
|
warn_if_params_used_in_provider_states(hash)
|
37
|
-
new(symbolize_keys(hash).merge(
|
37
|
+
new(symbolize_keys(hash).merge(contents: contents, provider_state: provider_state, metadata: metadata))
|
38
38
|
end
|
39
39
|
|
40
40
|
def to_hash
|
41
41
|
{
|
42
42
|
description: description,
|
43
43
|
provider_states: [{ name: provider_state }],
|
44
|
-
|
44
|
+
contents: contents.to_hash,
|
45
45
|
metadata: metadata
|
46
46
|
}
|
47
47
|
end
|
@@ -68,7 +68,7 @@ module Pact
|
|
68
68
|
status: 200,
|
69
69
|
headers: {'Content-Type' => 'application/json'},
|
70
70
|
body: {
|
71
|
-
|
71
|
+
contents: contents
|
72
72
|
}
|
73
73
|
)
|
74
74
|
end
|
@@ -82,7 +82,7 @@ module Pact
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def validate!
|
85
|
-
raise Pact::InvalidMessageError.new(self) unless description &&
|
85
|
+
raise Pact::InvalidMessageError.new(self) unless description && contents
|
86
86
|
end
|
87
87
|
|
88
88
|
def == other
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Pact
|
2
|
+
class ConsumerContract
|
3
|
+
class Message
|
4
|
+
class Contents
|
5
|
+
include ActiveSupportSupport
|
6
|
+
include SymbolizeKeys
|
7
|
+
|
8
|
+
# Could technically be an array
|
9
|
+
def self.from_hash contents, options = {}
|
10
|
+
new(contents)
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize contents
|
14
|
+
@contents = contents
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
if @contents.is_a?(Hash) || @contents.is_a?(Array)
|
19
|
+
@contents.to_json
|
20
|
+
else
|
21
|
+
@contents.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def contents
|
26
|
+
@contents
|
27
|
+
end
|
28
|
+
|
29
|
+
def as_json
|
30
|
+
@contents
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module Pact
|
38
|
+
module Message
|
39
|
+
class Contents
|
40
|
+
def self.new *args
|
41
|
+
Pact::ConsumerContract::Message::Contents.new(*args)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.from_hash *args
|
45
|
+
Pact::ConsumerContract::Message::Contents.from_hash(*args)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/pact/message/cli.rb
CHANGED
@@ -23,11 +23,11 @@ module Pact
|
|
23
23
|
|
24
24
|
def send_message
|
25
25
|
# TODO handle matchers
|
26
|
-
yield @
|
26
|
+
yield @contents_string if block_given?
|
27
27
|
end
|
28
28
|
|
29
29
|
def handle_interaction_fully_defined(interaction)
|
30
|
-
@
|
30
|
+
@contents_string = interaction.contents.to_s
|
31
31
|
@interactions << interaction
|
32
32
|
@interaction_builder = nil
|
33
33
|
# TODO pull these from pact config
|
@@ -15,7 +15,7 @@ module Pact
|
|
15
15
|
def as_json options = {}
|
16
16
|
hash = { :description => message.description }
|
17
17
|
hash[:providerStates] = provider_states if message.provider_state
|
18
|
-
hash[:
|
18
|
+
hash[:contents] = extract_contents
|
19
19
|
hash[:matchingRules] = extract_matching_rules
|
20
20
|
fix_all_the_things hash
|
21
21
|
end
|
@@ -28,12 +28,12 @@ module Pact
|
|
28
28
|
|
29
29
|
attr_reader :message
|
30
30
|
|
31
|
-
def
|
32
|
-
message.
|
31
|
+
def decorate_contents
|
32
|
+
message.contents.as_json
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
36
|
-
Pact::Reification.from_term(message.
|
35
|
+
def extract_contents
|
36
|
+
Pact::Reification.from_term(message.contents.contents)
|
37
37
|
end
|
38
38
|
|
39
39
|
def provider_states
|
@@ -42,7 +42,7 @@ module Pact
|
|
42
42
|
|
43
43
|
def extract_matching_rules
|
44
44
|
{
|
45
|
-
body: Pact::MatchingRules.extract(message.
|
45
|
+
body: Pact::MatchingRules.extract(message.contents.contents, pact_specification_version: pact_specification_version)
|
46
46
|
}
|
47
47
|
end
|
48
48
|
|
data/lib/pact/message/version.rb
CHANGED
data/script/update-pact.sh
CHANGED
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.
|
4
|
+
version: 0.4.3
|
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-
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pact-support
|
@@ -161,7 +161,7 @@ files:
|
|
161
161
|
- bin/pact-message
|
162
162
|
- bin/setup
|
163
163
|
- lib/pact/consumer_contract/message.rb
|
164
|
-
- lib/pact/consumer_contract/message/
|
164
|
+
- lib/pact/consumer_contract/message/contents.rb
|
165
165
|
- lib/pact/message.rb
|
166
166
|
- lib/pact/message/cli.rb
|
167
167
|
- lib/pact/message/consumer/configuration.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Pact
|
2
|
-
class ConsumerContract
|
3
|
-
class Message
|
4
|
-
class Content
|
5
|
-
include ActiveSupportSupport
|
6
|
-
include SymbolizeKeys
|
7
|
-
|
8
|
-
# Could technically be an array
|
9
|
-
def self.from_hash content, options = {}
|
10
|
-
new(content)
|
11
|
-
end
|
12
|
-
|
13
|
-
def initialize content
|
14
|
-
@content = content
|
15
|
-
end
|
16
|
-
|
17
|
-
def to_s
|
18
|
-
if @content.is_a?(Hash) || @content.is_a?(Array)
|
19
|
-
@content.to_json
|
20
|
-
else
|
21
|
-
@content.to_s
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def content
|
26
|
-
@content
|
27
|
-
end
|
28
|
-
|
29
|
-
def as_json
|
30
|
-
@content
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
module Pact
|
38
|
-
module Message
|
39
|
-
class Content
|
40
|
-
def self.new *args
|
41
|
-
Pact::ConsumerContract::Message::Content.new(*args)
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.from_hash *args
|
45
|
-
Pact::ConsumerContract::Message::Content.from_hash(*args)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|