pact-mock_service 3.2.1 → 3.3.1

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: 8f5c4344c8cd4ad35c428bba1596877909fc81cfda1eaae0a71e80521d3129f2
4
- data.tar.gz: 436534d7b43f1f60917c050abae962104dcc9650b6eb2d3df55e3dbc73509b44
3
+ metadata.gz: 32f3c85c10bc2898b76fe8227dae566f5df1c3ca278c52c33746675c6cd4ee5b
4
+ data.tar.gz: 50c30612bd46328d7abd0222c55a00ad65cfe14186eb39629c60607132acc694
5
5
  SHA512:
6
- metadata.gz: c45bb5349e99a7ae0b51ec8e281491f5c8075686d5bf91aa4d4ea89646fee9948339fdccab42d3fb01234cf83aa2241faf8d4c301f533fc9c70b6c9f4210c430
7
- data.tar.gz: 3eab8a731f151768b7fc7bab4f7002ec947a0f38c59aca9bef54a856cf4535a5de2ec665aef8b54c9cae966f6cfdfa78e7319770d09e28e82cbf738612654949
6
+ metadata.gz: 1cd9736792a6e43f1a7a4f5ea5474606162df1cdb52c9b5b3d3cb6d56b27ebae256549b129fded2974c55827b3d6e32174a03fa0be5afd96989c368d8221173c
7
+ data.tar.gz: a1e9b450d0a638cd9513cc33f75f1e10084642490e938c4491221c8ced0f8d10418390894d82440e1a0033af7ed28b6318fce16850e0dacc8ce9492cbd15ffd1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ <a name="v3.3.1"></a>
2
+ ### v3.3.1 (2020-01-16)
3
+
4
+
5
+ #### Bug Fixes
6
+
7
+ * put metadata on the correct decorator ([67ef5a6](/../../commit/67ef5a6))
8
+
9
+
10
+ <a name="v3.3.0"></a>
11
+ ### v3.3.0 (2020-01-16)
12
+
13
+
14
+ #### Features
15
+
16
+ * log a warning when too many interactions are set on the mock service at once ([0ce6bef](/../../commit/0ce6bef))
17
+
18
+
1
19
  <a name="v3.2.1"></a>
2
20
  ### v3.2.1 (2020-01-11)
3
21
 
@@ -17,7 +17,6 @@ module Pact
17
17
  hash[:providerState] = interaction.provider_state if interaction.provider_state
18
18
  hash[:request] = decorate_request.as_json(options)
19
19
  hash[:response] = decorate_response.as_json(options)
20
- hash[:metadata] = interaction.metadata
21
20
  fix_all_the_things hash
22
21
  end
23
22
 
@@ -15,12 +15,12 @@ module Pact
15
15
  end
16
16
 
17
17
  class App
18
-
19
18
  def initialize options = {}
20
19
  logger = Logger.from_options(options)
20
+ stubbing = options[:stub_pactfile_paths] && options[:stub_pactfile_paths].any?
21
21
  @name = options.fetch(:name, "MockService")
22
- @session = Session.new(options.merge(logger: logger))
23
- setup_stub(options[:stub_pactfile_paths]) if options[:stub_pactfile_paths]
22
+ @session = Session.new(options.merge(logger: logger, warn_on_too_many_interactions: !stubbing))
23
+ setup_stub(options[:stub_pactfile_paths]) if stubbing
24
24
  request_handlers = RequestHandlers.new(@name, logger, @session, options)
25
25
  @app = Rack::Builder.app do
26
26
  use Pact::Consumer::MockService::ErrorHandler, logger
@@ -28,6 +28,7 @@ module Pact
28
28
  hash[:providerState] = interaction.provider_state if interaction.provider_state
29
29
  hash[:request] = decorate_request.as_json
30
30
  hash[:response] = decorate_response.as_json
31
+ hash[:metadata] = interaction.metadata
31
32
  hash
32
33
  end
33
34
 
@@ -17,6 +17,8 @@ module Pact
17
17
  @expected_interactions = Interactions::ExpectedInteractions.new
18
18
  @actual_interactions = Interactions::ActualInteractions.new
19
19
  @verified_interactions = Interactions::VerifiedInteractions.new
20
+ @warn_on_too_many_interactions = options[:warn_on_too_many_interactions] || false
21
+ @max_concurrent_interactions_before_warning = get_max_concurrent_interactions_before_warning
20
22
  @consumer_contract_details = {
21
23
  pact_dir: options[:pact_dir],
22
24
  consumer: {name: options[:consumer]},
@@ -64,10 +66,15 @@ module Pact
64
66
 
65
67
  private
66
68
 
69
+ attr_reader :warn_on_too_many_interactions, :max_concurrent_interactions_before_warning
70
+
67
71
  def really_add_expected_interaction interaction
68
72
  expected_interactions << interaction
69
73
  logger.info "Registered expected interaction #{interaction.request.method_and_path}"
70
74
  logger.debug JSON.pretty_generate InteractionDecorator.new(interaction)
75
+ if warn_on_too_many_interactions && expected_interactions.size > max_concurrent_interactions_before_warning
76
+ logger.warn "You currently have #{expected_interactions.size} interactions mocked at the same time. This suggests the scope of your consumer tests is larger than recommended, and you may find them hard to debug and maintain. See https://pact.io/too-many-interactions for more information."
77
+ end
71
78
  end
72
79
 
73
80
  def handle_almost_duplicate_interaction previous_interaction, interaction
@@ -81,6 +88,9 @@ module Pact
81
88
  other && other != interaction ? other : nil
82
89
  end
83
90
 
91
+ def get_max_concurrent_interactions_before_warning
92
+ ENV['PACT_MAX_CONCURRENT_INTERACTIONS_BEFORE_WARNING'] ? ENV['PACT_MAX_CONCURRENT_INTERACTIONS_BEFORE_WARNING'].to_i : 3
93
+ end
84
94
  end
85
95
  end
86
96
  end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module MockService
3
- VERSION = "3.2.1"
3
+ VERSION = "3.3.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-mock_service
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2020-01-11 00:00:00.000000000 Z
15
+ date: 2020-01-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rack