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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b69c1a3041e520ebf876b90ce472ab23c579fa93fe53c69692a6d3c0e553d918
4
- data.tar.gz: ba41cb38a04d6756e5153383010173a353211ce31bdcf19df82d62c808647db8
3
+ metadata.gz: 276731375be178d95795d5e004e395c1412272b287758e5b63939470a79cfcd3
4
+ data.tar.gz: fcecdd27c44dae3f26a8a6cc8d989e5267d6efda0f43432a2552d96666db90c8
5
5
  SHA512:
6
- metadata.gz: e4480d684b2ed592ebd33ee1b5463fc5a981fabd50805e3575da99be51950b962fae5265bdc4a08d1ec2837a39509c22b3e6b95198b1d3705a4fa1590b3599fe
7
- data.tar.gz: 4f5e2c69d1b4ae613ae030f859580546bd7d364d9df421b546bce5aaeffdf899a8d48c397a8bc6b9a545d88540703752e0b475a6b3092df4e898bc53ade013c1
6
+ metadata.gz: b42530f66daf019dd4a059615816da2f515c97c1464ee83d646b6ac28e5d8de8e632b4552cabaa17309a17b0066bd21526cc0199fcf36b1bac92ab983dd50239
7
+ data.tar.gz: 9f1b41f7b0a507738f2224606bb94bc60db8ac3679895b4b15fe92080d591e98238f468e01a61b51473a30a10629528edacb68ec2e4c37deb1d2e2179a66656c
data/bin/coach CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "coach/cli/provider_finder"
4
+ require "coach/version"
4
5
  require "commander"
5
6
 
6
7
  module Coach
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coach
4
- VERSION = "2.2.1"
4
+ VERSION = "2.2.2"
5
5
  end
@@ -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 Metrics/LineLength
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
- let(:a_double) { double }
23
- let(:b_double) { double }
22
+ context "with multiple middleware" do
23
+ let(:a_double) { double }
24
+ let(:b_double) { double }
24
25
 
25
- before do
26
- terminal_middleware.uses(middleware_a, callback: a_double)
27
- terminal_middleware.uses(middleware_b, callback: b_double)
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
- it "invokes all middleware in the chain" do
31
- expect(a_double).to receive(:call)
32
- expect(b_double).to receive(:call)
33
- result = handler.call({})
34
- expect(result).to eq(%w[A{} B{} Terminal{:handler=>true}])
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.1
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-06 00:00:00.000000000 Z
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
- rubyforge_project:
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