pact-mock_service 3.2.1 → 3.3.0
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 +9 -0
- data/lib/pact/mock_service/app.rb +3 -3
- data/lib/pact/mock_service/session.rb +10 -0
- data/lib/pact/mock_service/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70978afac2d8baa00d8723c1852b88652bb9988498adc9ea1077aa6f11a0e5d1
|
4
|
+
data.tar.gz: 2d328532b86c3b2deb265b26770a6c2b72282e3d6fd4fdfeff6237fe0f1a965d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4621e740a4d865554ab7186547275b079955277d0c1883f31cde9c5932e56b1f3f17226edb8cd82738790b81c86cae28070f3c636c2041357a125915af55ec8e
|
7
|
+
data.tar.gz: bb71b263fd9663676f90a58f8b5198f7bebcc346677151269eba80c9c5d0a3a4bc8bf9d434d4a354e09c57515c4233ef6ee467e5126c35a3b59ecb1d31ccbd9a
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
@@ -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
|
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.
|
4
|
+
version: 3.3.0
|
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-
|
15
|
+
date: 2020-01-15 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rack
|