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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef9df4e508dca614f25914df88e80e1871316975
4
- data.tar.gz: 93bdc495602316c7b62b0a4b40ec356162f03a60
3
+ metadata.gz: c298a5c26b7e2525401462a2e295bc3b8e7e176c
4
+ data.tar.gz: a442288d24e1a72fdb9a55add17e14649007e08e
5
5
  SHA512:
6
- metadata.gz: bb5765686e2fab5838b7a92b6872a231f70d928849f94bc4c397f44a019ef09a41bf0221eddc12c04f591f92ce11a053002e206629ed2874fded5a579d43b35c
7
- data.tar.gz: 5546f4ae753b1590d8f13efcfe8951b8496bc2e3a647410b1266f285bfad034df6aa17b91ddd0be96c0966576dbaf5e86dd6e1d4db940d4bbb99fd88470b90ef
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/content'
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/content'
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, :content, :provider_state, :metadata
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
- @content = attributes[:content]
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
- content_matching_rules = hash['matchingRules'] && hash['matchingRules']['body']
31
- content_hash = Pact::MatchingRules.merge(hash['content'], content_matching_rules, opts)
32
- content = Pact::ConsumerContract::Message::Content.from_hash(content_hash)
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(content: content, provider_state: provider_state, metadata: metadata))
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
- content: content.to_hash,
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
- content: content
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 && content
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
@@ -23,6 +23,11 @@ module Pact
23
23
  require 'pact/support'
24
24
  puts Pact::Reification.from_term(JSON.load(json)).to_json
25
25
  end
26
+
27
+ def version
28
+ require 'pact/message/version.rb'
29
+ puts Pact::Message::VERSION
30
+ end
26
31
  end
27
32
  end
28
33
  end
@@ -23,11 +23,11 @@ module Pact
23
23
 
24
24
  def send_message
25
25
  # TODO handle matchers
26
- yield @content_string if block_given?
26
+ yield @contents_string if block_given?
27
27
  end
28
28
 
29
29
  def handle_interaction_fully_defined(interaction)
30
- @content_string = interaction.content.to_s
30
+ @contents_string = interaction.contents.to_s
31
31
  @interactions << interaction
32
32
  @interaction_builder = nil
33
33
  # TODO pull these from pact config
@@ -28,7 +28,7 @@ module Pact
28
28
  end
29
29
 
30
30
  def with_content(object)
31
- interaction.content = Pact::Message::Content.from_hash(object)
31
+ interaction.contents = Pact::Message::Contents.from_hash(object)
32
32
  @callback.call interaction
33
33
  self
34
34
  end
@@ -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[:content] = extract_content
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 decorate_content
32
- message.content.as_json
31
+ def decorate_contents
32
+ message.contents.as_json
33
33
  end
34
34
 
35
- def extract_content
36
- Pact::Reification.from_term(message.content.content)
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.content.content, pact_specification_version: pact_specification_version)
45
+ body: Pact::MatchingRules.extract(message.contents.contents, pact_specification_version: pact_specification_version)
46
46
  }
47
47
  end
48
48
 
@@ -1,6 +1,6 @@
1
1
  require 'pact/consumer_contract'
2
2
  require 'pact/consumer_contract/message'
3
- require 'pact/consumer_contract/message/content'
3
+ require 'pact/consumer_contract/message/contents'
4
4
 
5
5
  module Pact
6
6
  module Message
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module Message
3
- VERSION = "0.4.1"
3
+ VERSION = "0.4.3"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ bundle exec bin/pact-message update '{
5
5
  "name": "an alligator named Mary exists"
6
6
  }
7
7
  ],
8
- "content": {
8
+ "contents": {
9
9
  "name": {
10
10
  "contents": "Mary",
11
11
  "json_class": "Pact::SomethingLike"
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.1
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-04-05 00:00:00.000000000 Z
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/content.rb
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