pact 2.1.1 → 2.1.2

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
  SHA256:
3
- metadata.gz: f0938fad8f436d5e1e6f143ec47f38ac8ff9de8891c85f3327c51a512d007409
4
- data.tar.gz: 4f550fb8e2b8890e298a17d9b176aedf919baec7c84feaee0049c80ad4789d0d
3
+ metadata.gz: 8e137113e8536b4b90aa2f7797511680e7ece3b71f8ab5d9b79b55dafc88b326
4
+ data.tar.gz: e3f74756da104c116691133610e8f8dfcfa0abe5abc1bd26bceaaef3e98f5253
5
5
  SHA512:
6
- metadata.gz: 5f7fc288b6d58e1fb87e4e9f216d19434c41c94f4ab2e39d8bc9f88fdb332f682bdc0e5c4c505569c058da9b96c8378bd2d60dc63cbe0194276ff93228515a3a
7
- data.tar.gz: 4a07df495c3984d5b5344ce7c1b92496f69da4f888f18027184638480df328f71bcc57f8a73b03d696ad3d56ba2ee245119382b9dd16653e8d67a0740ad6b005
6
+ metadata.gz: 5656437ede72b86ff539d7c767f50ee0a55414df06e4d81c02cb87c24b27aca3e59eafdb4ed97eb76f2acc46aef69102f44a62c2366db5b81c975de32c2c721a
7
+ data.tar.gz: bf032fb5bfbd5e9a9fadc2fe60658ff4de346b62c5e4e94d8d52a835db9792885fb98258203ba721619c9ffe6839877e4538fd2e9a66df53bafbbb53fed36b1d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ <a name="v2.1.2"></a>
2
+ ### v2.1.2 (2026-10-21)
3
+
4
+ #### Bug Fixes
5
+
6
+ * support plugin message contents without a transport ([c3e4844](/../../commit/c3e4844))
7
+ * remove pact bin for cli no longer packaged in v2 ([fc5b182](/../../commit/fc5b182))
8
+
1
9
  <a name="v2.1.1"></a>
2
10
  ### v2.1.1 (2026-10-19)
3
11
 
@@ -55,6 +55,10 @@ module Pact
55
55
  @proto_path = nil
56
56
  @proto_message_class = nil
57
57
  @proto_include_dirs = []
58
+ @plugin_name = nil
59
+ @plugin_version = nil
60
+ @plugin_content_type = nil
61
+ @plugin_contents = nil
58
62
  @meta = {}
59
63
  @headers = {}
60
64
  @provider_state_meta = nil
@@ -106,6 +110,25 @@ module Pact
106
110
  self
107
111
  end
108
112
 
113
+ # Any content plugin that needs no transport (e.g. avro), see #with_plugin_contents
114
+ def with_plugin(plugin_name, plugin_version)
115
+ raise InteractionBuilderError.new("plugin_name is required") if plugin_name.blank?
116
+ raise InteractionBuilderError.new("plugin_version is required") if plugin_version.blank?
117
+
118
+ @plugin_name = plugin_name
119
+ @plugin_version = plugin_version
120
+ self
121
+ end
122
+
123
+ # contents_hash is passed to the plugin as-is, e.g. {"pact:avro" => path, "pact:record-name" => "Order", ...}
124
+ def with_plugin_contents(content_type, contents_hash)
125
+ raise InteractionBuilderError.new("content_type is required") if content_type.blank?
126
+
127
+ @plugin_content_type = content_type
128
+ @plugin_contents = InteractionContents.plugin(contents_hash)
129
+ self
130
+ end
131
+
109
132
  def with_metadata(meta_hash)
110
133
  @meta = InteractionContents.basic(meta_hash)
111
134
  self
@@ -122,7 +145,10 @@ module Pact
122
145
  end
123
146
 
124
147
  def validate!
125
- if proto_interaction?
148
+ if custom_plugin_interaction?
149
+ raise InteractionBuilderError.new("plugin is not defined, please set one with #with_plugin") if @plugin_name.blank? || @plugin_version.blank?
150
+ raise InteractionBuilderError.new("invalid request format, should be a hash") unless @plugin_contents.is_a?(Hash)
151
+ elsif proto_interaction?
126
152
  raise InteractionBuilderError.new("proto_path / proto_message are not defined, please set ones with #with_proto_message") if @proto_contents.blank? || @proto_message_class.blank?
127
153
  raise InteractionBuilderError.new("invalid request format, should be a hash") unless @proto_contents.is_a?(Hash)
128
154
  else
@@ -136,7 +162,7 @@ module Pact
136
162
 
137
163
  validate!
138
164
  pact_handle = init_pact
139
- init_plugin!(pact_handle) if proto_interaction?
165
+ init_plugin!(pact_handle) if plugin_interaction?
140
166
 
141
167
  message_pact = PactFfi::MessageConsumer.new_message_interaction(pact_handle, @description)
142
168
 
@@ -163,6 +189,7 @@ module Pact
163
189
  end
164
190
 
165
191
  def build_interaction_json
192
+ return JSON.dump({"pact:content-type" => @plugin_content_type}.merge(@plugin_contents.transform_keys(&:to_s))) if custom_plugin_interaction?
166
193
  return JSON.dump(@json_contents) unless proto_interaction?
167
194
 
168
195
  contents = {
@@ -240,7 +267,7 @@ module Pact
240
267
  end
241
268
 
242
269
  def fetch_reified_message_body(message_handle)
243
- if proto_interaction?
270
+ if plugin_interaction?
244
271
  len = PactFfi::MessageConsumer.get_contents_length(message_handle)
245
272
  ptr = PactFfi::MessageConsumer.get_contents_bin(message_handle)
246
273
  return nil if ptr.blank? || len == 0
@@ -257,8 +284,8 @@ module Pact
257
284
  def configure_interaction!(message_pact)
258
285
  interaction_json = build_interaction_json
259
286
 
260
- if proto_interaction?
261
- result = PactFfi::PluginConsumer.interaction_contents(message_pact, 0, PROTO_CONTENT_TYPE, interaction_json)
287
+ if plugin_interaction?
288
+ result = PactFfi::PluginConsumer.interaction_contents(message_pact, 0, plugin_content_type, interaction_json)
262
289
  if CREATE_INTERACTION_ERRORS[result].present?
263
290
  error = CREATE_INTERACTION_ERRORS[result]
264
291
  raise CreateInteractionError.new("There was an error while trying to add interaction \"#{@description}\"", error[:reason], error[:status])
@@ -277,11 +304,12 @@ module Pact
277
304
  end
278
305
 
279
306
  def init_plugin!(pact_handle)
280
- result = PactFfi::PluginConsumer.using_plugin(pact_handle, PROTOBUF_PLUGIN_NAME, @proto_plugin_version || PROTOBUF_PLUGIN_VERSION)
307
+ name, version = custom_plugin_interaction? ? [@plugin_name, @plugin_version] : [PROTOBUF_PLUGIN_NAME, @proto_plugin_version || PROTOBUF_PLUGIN_VERSION]
308
+ result = PactFfi::PluginConsumer.using_plugin(pact_handle, name, version)
281
309
  return result if INIT_PLUGIN_ERRORS[result].blank?
282
310
 
283
311
  error = INIT_PLUGIN_ERRORS[result]
284
- raise PluginInitError.new("There was an error while trying to initialize plugin #{PROTOBUF_PLUGIN_NAME}/#{@proto_plugin_version || PROTOBUF_PLUGIN_VERSION}", error[:reason], error[:status])
312
+ raise PluginInitError.new("There was an error while trying to initialize plugin #{name}/#{version}", error[:reason], error[:status])
285
313
  end
286
314
 
287
315
  def serialize_metadata(metadata_hash)
@@ -294,6 +322,18 @@ module Pact
294
322
  def proto_interaction?
295
323
  @proto_contents.present?
296
324
  end
325
+
326
+ def custom_plugin_interaction?
327
+ @plugin_contents.present?
328
+ end
329
+
330
+ def plugin_interaction?
331
+ proto_interaction? || custom_plugin_interaction?
332
+ end
333
+
334
+ def plugin_content_type
335
+ custom_plugin_interaction? ? @plugin_content_type : PROTO_CONTENT_TYPE
336
+ end
297
337
  end
298
338
  end
299
339
  end
data/lib/pact/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "2.1.1"
3
+ VERSION = "2.1.2"
4
4
  end
data/pact.gemspec CHANGED
@@ -14,8 +14,7 @@ Gem::Specification.new do |gem|
14
14
 
15
15
  gem.required_ruby_version = '>= 2.0'
16
16
 
17
- gem.files = `git ls-files bin lib pact.gemspec CHANGELOG.md LICENSE.txt`.split($/)
18
- gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
+ gem.files = `git ls-files lib pact.gemspec CHANGELOG.md LICENSE.txt`.split($/)
19
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
19
  gem.require_paths = ['lib']
21
20
  gem.license = 'MIT'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -406,14 +406,12 @@ email:
406
406
  - brent@fuglylogic.com
407
407
  - uglyog@gmail.com
408
408
  - bskurrie@dius.com.au
409
- executables:
410
- - pact
409
+ executables: []
411
410
  extensions: []
412
411
  extra_rdoc_files: []
413
412
  files:
414
413
  - CHANGELOG.md
415
414
  - LICENSE.txt
416
- - bin/pact
417
415
  - lib/pact.rb
418
416
  - lib/pact/configuration.rb
419
417
  - lib/pact/consumer.rb
data/bin/pact DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'pact/cli'
4
- Pact::CLI.start