coach 2.2.1 → 2.2.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 +4 -4
- data/bin/coach +1 -0
- data/lib/coach/version.rb +1 -1
- data/spec/lib/coach/cli/provider_finder_spec.rb +1 -1
- data/spec/lib/coach/handler_spec.rb +75 -75
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 276731375be178d95795d5e004e395c1412272b287758e5b63939470a79cfcd3
|
4
|
+
data.tar.gz: fcecdd27c44dae3f26a8a6cc8d989e5267d6efda0f43432a2552d96666db90c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b42530f66daf019dd4a059615816da2f515c97c1464ee83d646b6ac28e5d8de8e632b4552cabaa17309a17b0066bd21526cc0199fcf36b1bac92ab983dd50239
|
7
|
+
data.tar.gz: 9f1b41f7b0a507738f2224606bb94bc60db8ac3679895b4b15fe92080d591e98238f468e01a61b51473a30a10629528edacb68ec2e4c37deb1d2e2179a66656c
|
data/bin/coach
CHANGED
data/lib/coach/version.rb
CHANGED
@@ -201,7 +201,7 @@ describe Coach::Cli::ProviderFinder do
|
|
201
201
|
expect(provider_finder.find_chain).
|
202
202
|
to eq([
|
203
203
|
%w[FirstProvidingMiddleware FirstIntermediateMiddleware RequiringMiddleware],
|
204
|
-
%w[SecondProvidingMiddleware SecondIntermediateMiddleware RequiringMiddleware], # rubocop:disable
|
204
|
+
%w[SecondProvidingMiddleware SecondIntermediateMiddleware RequiringMiddleware], # rubocop:disable Layout/LineLength
|
205
205
|
].to_set)
|
206
206
|
end
|
207
207
|
end
|
@@ -19,19 +19,84 @@ describe Coach::Handler do
|
|
19
19
|
before { Coach::Notifications.unsubscribe! }
|
20
20
|
|
21
21
|
describe "#call" do
|
22
|
-
|
23
|
-
|
22
|
+
context "with multiple middleware" do
|
23
|
+
let(:a_double) { double }
|
24
|
+
let(:b_double) { double }
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
before do
|
27
|
+
terminal_middleware.uses(middleware_a, callback: a_double)
|
28
|
+
terminal_middleware.uses(middleware_b, callback: b_double)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "invokes all middleware in the chain" do
|
32
|
+
expect(a_double).to receive(:call)
|
33
|
+
expect(b_double).to receive(:call)
|
34
|
+
result = handler.call({})
|
35
|
+
expect(result).to eq(%w[A{} B{} Terminal{:handler=>true}])
|
36
|
+
end
|
28
37
|
end
|
29
38
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
39
|
+
describe "notifications" do
|
40
|
+
subject(:coach_events) do
|
41
|
+
events = []
|
42
|
+
subscription = ActiveSupport::Notifications.
|
43
|
+
subscribe(/\.coach$/) { |name, *_args| events << name }
|
44
|
+
|
45
|
+
handler.call({})
|
46
|
+
ActiveSupport::Notifications.unsubscribe(subscription)
|
47
|
+
events
|
48
|
+
end
|
49
|
+
|
50
|
+
before do
|
51
|
+
terminal_middleware.uses(middleware_a)
|
52
|
+
|
53
|
+
Coach::Notifications.subscribe!
|
54
|
+
|
55
|
+
# Prevent RequestSerializer from erroring due to insufficient request mock
|
56
|
+
allow(Coach::RequestSerializer).
|
57
|
+
to receive(:new).
|
58
|
+
and_return(instance_double("Coach::RequestSerializer", serialize: {}))
|
59
|
+
end
|
60
|
+
|
61
|
+
it { is_expected.to include("start_handler.coach") }
|
62
|
+
it { is_expected.to include("start_middleware.coach") }
|
63
|
+
it { is_expected.to include("request.coach") }
|
64
|
+
it { is_expected.to include("finish_middleware.coach") }
|
65
|
+
it { is_expected.to include("finish_handler.coach") }
|
66
|
+
|
67
|
+
context "when an exception is raised in the chain" do
|
68
|
+
subject(:coach_events) do
|
69
|
+
events = []
|
70
|
+
subscription = ActiveSupport::Notifications.
|
71
|
+
subscribe(/\.coach$/) do |name, *args|
|
72
|
+
events << [name, args.last]
|
73
|
+
end
|
74
|
+
|
75
|
+
begin
|
76
|
+
handler.call({})
|
77
|
+
rescue StandardError
|
78
|
+
:continue_anyway
|
79
|
+
end
|
80
|
+
ActiveSupport::Notifications.unsubscribe(subscription)
|
81
|
+
events
|
82
|
+
end
|
83
|
+
|
84
|
+
let(:explosive_action) { -> { raise "AH" } }
|
85
|
+
|
86
|
+
before { terminal_middleware.uses(middleware_a, callback: explosive_action) }
|
87
|
+
|
88
|
+
it "captures the error event with the metadata" do
|
89
|
+
expect(coach_events).
|
90
|
+
to include(["finish_handler.coach", hash_including(
|
91
|
+
response: { status: 500 },
|
92
|
+
metadata: { A: true },
|
93
|
+
)])
|
94
|
+
end
|
95
|
+
|
96
|
+
it "bubbles the error to the next handler" do
|
97
|
+
expect { handler.call({}) }.to raise_error(StandardError, "AH")
|
98
|
+
end
|
99
|
+
end
|
35
100
|
end
|
36
101
|
end
|
37
102
|
|
@@ -121,71 +186,6 @@ describe Coach::Handler do
|
|
121
186
|
end
|
122
187
|
end
|
123
188
|
|
124
|
-
describe "#call" do
|
125
|
-
before { terminal_middleware.uses(middleware_a) }
|
126
|
-
|
127
|
-
describe "notifications" do
|
128
|
-
subject(:coach_events) do
|
129
|
-
events = []
|
130
|
-
subscription = ActiveSupport::Notifications.
|
131
|
-
subscribe(/\.coach$/) { |name, *_args| events << name }
|
132
|
-
|
133
|
-
handler.call({})
|
134
|
-
ActiveSupport::Notifications.unsubscribe(subscription)
|
135
|
-
events
|
136
|
-
end
|
137
|
-
|
138
|
-
before do
|
139
|
-
Coach::Notifications.subscribe!
|
140
|
-
|
141
|
-
# Prevent RequestSerializer from erroring due to insufficient request mock
|
142
|
-
allow(Coach::RequestSerializer).
|
143
|
-
to receive(:new).
|
144
|
-
and_return(instance_double("Coach::RequestSerializer", serialize: {}))
|
145
|
-
end
|
146
|
-
|
147
|
-
it { is_expected.to include("start_handler.coach") }
|
148
|
-
it { is_expected.to include("start_middleware.coach") }
|
149
|
-
it { is_expected.to include("request.coach") }
|
150
|
-
it { is_expected.to include("finish_middleware.coach") }
|
151
|
-
it { is_expected.to include("finish_handler.coach") }
|
152
|
-
|
153
|
-
context "when an exception is raised in the chain" do
|
154
|
-
subject(:coach_events) do
|
155
|
-
events = []
|
156
|
-
subscription = ActiveSupport::Notifications.
|
157
|
-
subscribe(/\.coach$/) do |name, *args|
|
158
|
-
events << [name, args.last]
|
159
|
-
end
|
160
|
-
|
161
|
-
begin
|
162
|
-
handler.call({})
|
163
|
-
rescue StandardError
|
164
|
-
:continue_anyway
|
165
|
-
end
|
166
|
-
ActiveSupport::Notifications.unsubscribe(subscription)
|
167
|
-
events
|
168
|
-
end
|
169
|
-
|
170
|
-
let(:explosive_action) { -> { raise "AH" } }
|
171
|
-
|
172
|
-
before { terminal_middleware.uses(middleware_a, callback: explosive_action) }
|
173
|
-
|
174
|
-
it "captures the error event with the metadata" do
|
175
|
-
expect(coach_events).
|
176
|
-
to include(["finish_handler.coach", hash_including(
|
177
|
-
response: { status: 500 },
|
178
|
-
metadata: { A: true },
|
179
|
-
)])
|
180
|
-
end
|
181
|
-
|
182
|
-
it "bubbles the error to the next handler" do
|
183
|
-
expect { handler.call({}) }.to raise_error(StandardError, "AH")
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
189
|
describe "#inspect" do
|
190
190
|
its(:inspect) { is_expected.to eql("#<Coach::Handler[Terminal]>") }
|
191
191
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -185,8 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
|
-
|
189
|
-
rubygems_version: 2.7.6.2
|
188
|
+
rubygems_version: 3.1.2
|
190
189
|
signing_key:
|
191
190
|
specification_version: 4
|
192
191
|
summary: Alternative controllers built with middleware
|