spearly-sdk-ruby 0.9.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,44 +8,15 @@ RSpec.describe Spearly::Auth::Client do
8
8
  before do
9
9
  stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })
10
10
 
11
- allow(Faraday).to receive(:default_connection).and_return(connection_double)
11
+ allow(Faraday).to receive(:new).and_return(connection_double)
12
12
  end
13
13
 
14
- describe '.create_team()' do
15
- let!(:response_double) { instance_double(Faraday::Response, status: 201, body: { 'data' => { 'id' => '711' } }.to_json) }
16
- let!(:params) { { hey: 'jude' } }
17
- let!(:client) { described_class.new('token') }
18
-
19
- before do
20
- allow(connection_double).to receive(:post).and_return(response_double)
21
- end
22
-
23
- it 'makes POST request to /teams' do
24
- uri_parsed = Addressable::URI.parse('https://api.spearly.test/teams').normalize.to_s
25
-
26
- expect(connection_double).to receive(:post).with(uri_parsed,
27
- params.as_json,
28
- 'Accept' => 'application/vnd.spearly.v2+json',
29
- 'Authorization' => 'token')
14
+ it 'raises ServerError on Faraday::ConnectionFailed' do
15
+ allow(connection_double).to receive(:run_request).and_raise(Faraday::ConnectionFailed.new('Failed to open TCP connection to :80'))
30
16
 
17
+ expect do
31
18
  described_class.new('token')
32
- .create_team(params)
33
- end
34
-
35
- it 'returns data object if status is 201' do
36
- res = client.create_team(params)
37
-
38
- expect(res).to eq('id' => '711')
39
- end
40
-
41
- it 'returns errors object if status is 422' do
42
- response_double = instance_double(Faraday::Response, status: 422, body: { 'errors' => { 'owner' => ["can't own more than 2 free teams"] } }.to_json)
43
-
44
- allow(connection_double).to receive(:post).and_return(response_double)
45
-
46
- res = client.create_team(params)
47
-
48
- expect(res['errors']).to eq('owner' => ["can't own more than 2 free teams"])
49
- end
19
+ .run_request(:method => :get, path: '/connection_failed')
20
+ end.to raise_error(Spearly::Auth::ServerError, 'Failed to open TCP connection to :80')
50
21
  end
51
22
  end
@@ -0,0 +1,159 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Spearly::Auth::TeamMember do
6
+ let!(:connection_double) { instance_double(Faraday::Connection) }
7
+
8
+ before do
9
+ stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })
10
+
11
+ allow(Faraday).to receive(:new).and_return(connection_double)
12
+ end
13
+
14
+ describe '.invite_user_to_team()' do
15
+ let!(:response_double) { instance_double(Faraday::Response, status: 201, body: { 'data' => { 'id' => 'team_invitation_1' } }.to_json) }
16
+ let!(:team_id) { '711' }
17
+ let!(:client) { Spearly::Auth::Client.new('token') }
18
+
19
+ let!(:params) do
20
+ {
21
+ email: 'hey@jude.test',
22
+ roles: {
23
+ cms: 'admin',
24
+ cloud: 'developer'
25
+ }
26
+ }
27
+ end
28
+
29
+ before do
30
+ allow(connection_double).to receive(:run_request).and_return(response_double)
31
+ end
32
+
33
+ it 'makes POST request to /teams/:team_id/invite' do
34
+ uri_parsed = Addressable::URI.parse('/teams/711/invite').normalize.to_s
35
+
36
+ expect(connection_double).to receive(:run_request).with(:post,
37
+ uri_parsed,
38
+ params,
39
+ 'Accept' => 'application/vnd.spearly.v2+json',
40
+ 'Authorization' => 'token')
41
+
42
+ client.invite_user_to_team(team_id, params)
43
+ end
44
+
45
+ it 'returns data array if status is 201' do
46
+ res = client.invite_user_to_team(team_id, params)
47
+
48
+ expect(res).to eq('data' => { 'id' => 'team_invitation_1' })
49
+ end
50
+
51
+ it 'throws AuthorizationError if 401' do
52
+ response_double = instance_double(Faraday::Response, status: 401)
53
+
54
+ allow(connection_double).to receive(:run_request).and_return(response_double)
55
+
56
+ expect do
57
+ client.invite_user_to_team(team_id, params)
58
+ end.to raise_error(Spearly::Auth::AuthorizationError)
59
+ end
60
+
61
+ it 'throws NotFoundError if 404' do
62
+ response_double = instance_double(Faraday::Response, status: 404)
63
+
64
+ allow(connection_double).to receive(:run_request).and_return(response_double)
65
+
66
+ expect do
67
+ client.invite_user_to_team(team_id, params)
68
+ end.to raise_error(Spearly::Auth::NotFoundError)
69
+ end
70
+
71
+ it 'throws ServerError if 500' do
72
+ response_double = instance_double(Faraday::Response, status: 500)
73
+
74
+ allow(connection_double).to receive(:run_request).and_return(response_double)
75
+
76
+ expect do
77
+ client.invite_user_to_team(team_id, params)
78
+ end.to raise_error(Spearly::Auth::ServerError)
79
+ end
80
+
81
+ it 'throws ServiceUnavailableError if 503' do
82
+ response_double = instance_double(Faraday::Response, status: 503)
83
+
84
+ allow(connection_double).to receive(:run_request).and_return(response_double)
85
+
86
+ expect do
87
+ client.invite_user_to_team(team_id, params)
88
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
89
+ end
90
+ end
91
+
92
+ describe '.get_team_members()' do
93
+ let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => [{ 'id' => 'team_member_1' }] }.to_json) }
94
+ let!(:team_id) { '711' }
95
+ let!(:client) { Spearly::Auth::Client.new('token') }
96
+
97
+ before do
98
+ allow(connection_double).to receive(:run_request).and_return(response_double)
99
+ end
100
+
101
+ it 'makes GET request to /teams/:team_id/members' do
102
+ uri_parsed = Addressable::URI.parse('/teams/711/members').normalize.to_s
103
+
104
+ expect(connection_double).to receive(:run_request).with(:get,
105
+ uri_parsed,
106
+ nil,
107
+ 'Accept' => 'application/vnd.spearly.v2+json',
108
+ 'Authorization' => 'token')
109
+
110
+ client.get_team_members(team_id)
111
+ end
112
+
113
+ it 'returns data array if status is 200' do
114
+ res = client.get_team_members(team_id)
115
+
116
+ expect(res).to eq('data' => [{ 'id' => 'team_member_1' }])
117
+ end
118
+
119
+ it 'throws AuthorizationError if 401' do
120
+ response_double = instance_double(Faraday::Response, status: 401)
121
+
122
+ allow(connection_double).to receive(:run_request).and_return(response_double)
123
+
124
+ expect do
125
+ client.get_team_members(team_id)
126
+ end.to raise_error(Spearly::Auth::AuthorizationError)
127
+ end
128
+
129
+ it 'throws NotFoundError if 404' do
130
+ response_double = instance_double(Faraday::Response, status: 404)
131
+
132
+ allow(connection_double).to receive(:run_request).and_return(response_double)
133
+
134
+ expect do
135
+ client.get_team_members(team_id)
136
+ end.to raise_error(Spearly::Auth::NotFoundError)
137
+ end
138
+
139
+ it 'throws ServerError if 500' do
140
+ response_double = instance_double(Faraday::Response, status: 500)
141
+
142
+ allow(connection_double).to receive(:run_request).and_return(response_double)
143
+
144
+ expect do
145
+ client.get_team_members(team_id)
146
+ end.to raise_error(Spearly::Auth::ServerError)
147
+ end
148
+
149
+ it 'throws ServiceUnavailableError if 503' do
150
+ response_double = instance_double(Faraday::Response, status: 503)
151
+
152
+ allow(connection_double).to receive(:run_request).and_return(response_double)
153
+
154
+ expect do
155
+ client.get_team_members(team_id)
156
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,371 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Spearly::Auth::Team do
6
+ let!(:connection_double) { instance_double(Faraday::Connection) }
7
+
8
+ before do
9
+ stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })
10
+
11
+ allow(Faraday).to receive(:new).and_return(connection_double)
12
+ end
13
+
14
+ describe '.create_team()' do
15
+ let!(:response_double) { instance_double(Faraday::Response, status: 201, body: { 'data' => { 'id' => 'team_1' } }.to_json) }
16
+ let!(:params) { { hey: 'jude' } }
17
+ let!(:client) { Spearly::Auth::Client.new('token') }
18
+
19
+ before do
20
+ allow(connection_double).to receive(:run_request).and_return(response_double)
21
+ end
22
+
23
+ it 'makes POST request to /teams' do
24
+ uri_parsed = Addressable::URI.parse('/teams').normalize.to_s
25
+
26
+ expect(connection_double).to receive(:run_request).with(:post,
27
+ uri_parsed,
28
+ params,
29
+ 'Accept' => 'application/vnd.spearly.v2+json',
30
+ 'Authorization' => 'token')
31
+
32
+ client.create_team(params)
33
+ end
34
+
35
+ it 'returns object if 201' do
36
+ res = client.create_team(params)
37
+
38
+ expect(res).to eq('data' => { 'id' => 'team_1' })
39
+ end
40
+
41
+ it 'returns errors object if 422' do
42
+ response_double = instance_double(Faraday::Response, status: 422, body: { 'errors' => { 'owner' => ["can't own more than 2 free teams"] } }.to_json)
43
+
44
+ allow(connection_double).to receive(:run_request).and_return(response_double)
45
+
46
+ res = client.create_team(params)
47
+
48
+ expect(res['errors']).to eq('owner' => ["can't own more than 2 free teams"])
49
+ end
50
+
51
+ it 'throws AuthorizationError if 401' do
52
+ response_double = instance_double(Faraday::Response, status: 401)
53
+
54
+ allow(connection_double).to receive(:run_request).and_return(response_double)
55
+
56
+ expect do
57
+ client.create_team(params)
58
+ end.to raise_error(Spearly::Auth::AuthorizationError)
59
+ end
60
+
61
+ it 'throws NotFoundError if 404' do
62
+ response_double = instance_double(Faraday::Response, status: 404)
63
+
64
+ allow(connection_double).to receive(:run_request).and_return(response_double)
65
+
66
+ expect do
67
+ client.create_team(params)
68
+ end.to raise_error(Spearly::Auth::NotFoundError)
69
+ end
70
+
71
+ it 'throws ServerError if 500' do
72
+ response_double = instance_double(Faraday::Response, status: 500)
73
+
74
+ allow(connection_double).to receive(:run_request).and_return(response_double)
75
+
76
+ expect do
77
+ client.create_team(params)
78
+ end.to raise_error(Spearly::Auth::ServerError)
79
+ end
80
+
81
+ it 'throws ServiceUnavailableError if 503' do
82
+ response_double = instance_double(Faraday::Response, status: 503)
83
+
84
+ allow(connection_double).to receive(:run_request).and_return(response_double)
85
+
86
+ expect do
87
+ client.create_team(params)
88
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
89
+ end
90
+ end
91
+
92
+ describe '.get_team()' do
93
+ let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => { 'id' => 'team_1' } }.to_json) }
94
+ let!(:team_id) { 'team_1' }
95
+ let!(:client) { Spearly::Auth::Client.new('token') }
96
+
97
+ before do
98
+ allow(connection_double).to receive(:run_request).and_return(response_double)
99
+ end
100
+
101
+ it 'makes GET request to /teams/:team_id' do
102
+ uri_parsed = Addressable::URI.parse("/teams/#{team_id}").normalize.to_s
103
+
104
+ expect(connection_double).to receive(:run_request).with(:get,
105
+ uri_parsed,
106
+ nil,
107
+ 'Accept' => 'application/vnd.spearly.v2+json',
108
+ 'Authorization' => 'token')
109
+
110
+ client.get_team(team_id)
111
+ end
112
+
113
+ it 'returns data array if 200' do
114
+ res = client.get_team(team_id)
115
+
116
+ expect(res).to eq('data' => { 'id' => 'team_1' })
117
+ end
118
+
119
+ it 'throws AuthorizationError if 401' do
120
+ response_double = instance_double(Faraday::Response, status: 401)
121
+
122
+ allow(connection_double).to receive(:run_request).and_return(response_double)
123
+
124
+ expect do
125
+ client.get_team(team_id)
126
+ end.to raise_error(Spearly::Auth::AuthorizationError)
127
+ end
128
+
129
+ it 'throws NotFoundError if 404' do
130
+ response_double = instance_double(Faraday::Response, status: 404)
131
+
132
+ allow(connection_double).to receive(:run_request).and_return(response_double)
133
+
134
+ expect do
135
+ client.get_team(team_id)
136
+ end.to raise_error(Spearly::Auth::NotFoundError)
137
+ end
138
+
139
+ it 'throws ServerError if 500' do
140
+ response_double = instance_double(Faraday::Response, status: 500)
141
+
142
+ allow(connection_double).to receive(:run_request).and_return(response_double)
143
+
144
+ expect do
145
+ client.get_team(team_id)
146
+ end.to raise_error(Spearly::Auth::ServerError)
147
+ end
148
+
149
+ it 'throws ServiceUnavailableError if 503' do
150
+ response_double = instance_double(Faraday::Response, status: 503)
151
+
152
+ allow(connection_double).to receive(:run_request).and_return(response_double)
153
+
154
+ expect do
155
+ client.get_team(team_id)
156
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
157
+ end
158
+ end
159
+
160
+ describe '.get_teams()' do
161
+ let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => [{ 'id' => 'team_1' }] }.to_json) }
162
+ let!(:params) { { service_name: 'cms' } }
163
+ let!(:client) { Spearly::Auth::Client.new('token') }
164
+
165
+ before do
166
+ allow(connection_double).to receive(:run_request).and_return(response_double)
167
+ end
168
+
169
+ it 'makes GET request to /teams' do
170
+ uri_parsed = Addressable::URI.parse('/teams').normalize.to_s
171
+
172
+ expect(connection_double).to receive(:run_request).with(:get,
173
+ uri_parsed,
174
+ params,
175
+ 'Accept' => 'application/vnd.spearly.v2+json',
176
+ 'Authorization' => 'token')
177
+
178
+ client.get_teams(params)
179
+ end
180
+
181
+ it 'returns data array if 200' do
182
+ res = client.get_teams(params)
183
+
184
+ expect(res).to eq('data' => [{ 'id' => 'team_1' }])
185
+ end
186
+
187
+ it 'throws AuthorizationError if 401' do
188
+ response_double = instance_double(Faraday::Response, status: 401)
189
+
190
+ allow(connection_double).to receive(:run_request).and_return(response_double)
191
+
192
+ expect do
193
+ client.get_teams(params)
194
+ end.to raise_error(Spearly::Auth::AuthorizationError)
195
+ end
196
+
197
+ it 'throws NotFoundError if 404' do
198
+ response_double = instance_double(Faraday::Response, status: 404)
199
+
200
+ allow(connection_double).to receive(:run_request).and_return(response_double)
201
+
202
+ expect do
203
+ client.get_teams(params)
204
+ end.to raise_error(Spearly::Auth::NotFoundError)
205
+ end
206
+
207
+ it 'throws ServerError if 500' do
208
+ response_double = instance_double(Faraday::Response, status: 500)
209
+
210
+ allow(connection_double).to receive(:run_request).and_return(response_double)
211
+
212
+ expect do
213
+ client.get_teams(params)
214
+ end.to raise_error(Spearly::Auth::ServerError)
215
+ end
216
+
217
+ it 'throws ServiceUnavailableError if 503' do
218
+ response_double = instance_double(Faraday::Response, status: 503)
219
+
220
+ allow(connection_double).to receive(:run_request).and_return(response_double)
221
+
222
+ expect do
223
+ client.get_teams(params)
224
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
225
+ end
226
+ end
227
+
228
+ describe '.update_team()' do
229
+ let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => { 'id' => 'team_1' } }.to_json) }
230
+ let!(:team_id) { 'team_1' }
231
+ let!(:client) { Spearly::Auth::Client.new('token') }
232
+
233
+ let!(:params) do
234
+ {
235
+ team: {
236
+ name: 'new name'
237
+ }
238
+ }
239
+ end
240
+
241
+ before do
242
+ allow(connection_double).to receive(:run_request).and_return(response_double)
243
+ end
244
+
245
+ it 'makes PUT request to /teams/:team_id' do
246
+ uri_parsed = Addressable::URI.parse("/teams/#{team_id}").normalize.to_s
247
+
248
+ expect(connection_double).to receive(:run_request).with(:put,
249
+ uri_parsed,
250
+ params,
251
+ 'Accept' => 'application/vnd.spearly.v2+json',
252
+ 'Authorization' => 'token')
253
+
254
+ client.update_team(team_id, params)
255
+ end
256
+
257
+ it 'returns data object if 200' do
258
+ res = client.update_team(team_id, params)
259
+
260
+ expect(res).to eq('data' => { 'id' => 'team_1' })
261
+ end
262
+
263
+ it 'throws AuthorizationError if 401' do
264
+ response_double = instance_double(Faraday::Response, status: 401)
265
+
266
+ allow(connection_double).to receive(:run_request).and_return(response_double)
267
+
268
+ expect do
269
+ client.update_team(team_id, params)
270
+ end.to raise_error(Spearly::Auth::AuthorizationError)
271
+ end
272
+
273
+ it 'throws NotFoundError if 404' do
274
+ response_double = instance_double(Faraday::Response, status: 404)
275
+
276
+ allow(connection_double).to receive(:run_request).and_return(response_double)
277
+
278
+ expect do
279
+ client.update_team(team_id, params)
280
+ end.to raise_error(Spearly::Auth::NotFoundError)
281
+ end
282
+
283
+ it 'throws ServerError if 500' do
284
+ response_double = instance_double(Faraday::Response, status: 500)
285
+
286
+ allow(connection_double).to receive(:run_request).and_return(response_double)
287
+
288
+ expect do
289
+ client.update_team(team_id, params)
290
+ end.to raise_error(Spearly::Auth::ServerError)
291
+ end
292
+
293
+ it 'throws ServiceUnavailableError if 503' do
294
+ response_double = instance_double(Faraday::Response, status: 503)
295
+
296
+ allow(connection_double).to receive(:run_request).and_return(response_double)
297
+
298
+ expect do
299
+ client.update_team(team_id, params)
300
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
301
+ end
302
+ end
303
+
304
+ describe '.regenerate_team_api_access_token()' do
305
+ let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => { 'id' => 'team_1' } }.to_json) }
306
+ let!(:team_id) { 'team_1' }
307
+ let!(:client) { Spearly::Auth::Client.new('token') }
308
+
309
+ before do
310
+ allow(connection_double).to receive(:run_request).and_return(response_double)
311
+ end
312
+
313
+ it 'makes GET request to /teams/:team_id/regenerate_api_access_token' do
314
+ uri_parsed = Addressable::URI.parse("/teams/#{team_id}/regenerate_api_access_token").normalize.to_s
315
+
316
+ expect(connection_double).to receive(:run_request).with(:get,
317
+ uri_parsed,
318
+ nil,
319
+ 'Accept' => 'application/vnd.spearly.v2+json',
320
+ 'Authorization' => 'token')
321
+
322
+ client.regenerate_team_api_access_token(team_id)
323
+ end
324
+
325
+ it 'returns data object if 200' do
326
+ res = client.regenerate_team_api_access_token(team_id)
327
+
328
+ expect(res).to eq('data' => { 'id' => 'team_1' })
329
+ end
330
+
331
+ it 'throws AuthorizationError if 401' do
332
+ response_double = instance_double(Faraday::Response, status: 401)
333
+
334
+ allow(connection_double).to receive(:run_request).and_return(response_double)
335
+
336
+ expect do
337
+ client.regenerate_team_api_access_token(team_id)
338
+ end.to raise_error(Spearly::Auth::AuthorizationError)
339
+ end
340
+
341
+ it 'throws NotFoundError if 404' do
342
+ response_double = instance_double(Faraday::Response, status: 404)
343
+
344
+ allow(connection_double).to receive(:run_request).and_return(response_double)
345
+
346
+ expect do
347
+ client.regenerate_team_api_access_token(team_id)
348
+ end.to raise_error(Spearly::Auth::NotFoundError)
349
+ end
350
+
351
+ it 'throws ServerError if 500' do
352
+ response_double = instance_double(Faraday::Response, status: 500)
353
+
354
+ allow(connection_double).to receive(:run_request).and_return(response_double)
355
+
356
+ expect do
357
+ client.regenerate_team_api_access_token(team_id)
358
+ end.to raise_error(Spearly::Auth::ServerError)
359
+ end
360
+
361
+ it 'throws ServiceUnavailableError if 503' do
362
+ response_double = instance_double(Faraday::Response, status: 503)
363
+
364
+ allow(connection_double).to receive(:run_request).and_return(response_double)
365
+
366
+ expect do
367
+ client.regenerate_team_api_access_token(team_id)
368
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
369
+ end
370
+ end
371
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Spearly::Auth::TeamSubscription do
6
+ let!(:connection_double) { instance_double(Faraday::Connection) }
7
+
8
+ before do
9
+ stub_const('ENV', { 'SPEARLY_API_URL' => 'https://api.spearly.test' })
10
+
11
+ allow(Faraday).to receive(:new).and_return(connection_double)
12
+ end
13
+
14
+ describe '.get_team_subscriptions()' do
15
+ let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => [{ 'id' => 'sub_1' }] }.to_json) }
16
+ let!(:team_id) { '711' }
17
+ let!(:params) { { service_name: 'cms' } }
18
+ let!(:client) { Spearly::Auth::Client.new('token') }
19
+
20
+ before do
21
+ allow(connection_double).to receive(:run_request).and_return(response_double)
22
+ end
23
+
24
+ it 'makes GET request to /teams/:team_id/subscriptions' do
25
+ uri_parsed = Addressable::URI.parse('/teams/711/subscriptions').normalize.to_s
26
+
27
+ expect(connection_double).to receive(:run_request).with(:get,
28
+ uri_parsed,
29
+ params,
30
+ 'Accept' => 'application/vnd.spearly.v2+json',
31
+ 'Authorization' => 'token')
32
+
33
+ client.get_team_subscriptions(team_id, params)
34
+ end
35
+
36
+ it 'returns data array if status is 200' do
37
+ res = client.get_team_subscriptions(team_id, params)
38
+
39
+ expect(res).to eq('data' => [{ 'id' => 'sub_1' }])
40
+ end
41
+
42
+ it 'throws AuthorizationError if 401' do
43
+ response_double = instance_double(Faraday::Response, status: 401)
44
+
45
+ allow(connection_double).to receive(:run_request).and_return(response_double)
46
+
47
+ expect do
48
+ client.get_team_subscriptions(team_id, params)
49
+ end.to raise_error(Spearly::Auth::AuthorizationError)
50
+ end
51
+
52
+ it 'throws NotFoundError if 404' do
53
+ response_double = instance_double(Faraday::Response, status: 404)
54
+
55
+ allow(connection_double).to receive(:run_request).and_return(response_double)
56
+
57
+ expect do
58
+ client.get_team_subscriptions(team_id, params)
59
+ end.to raise_error(Spearly::Auth::NotFoundError)
60
+ end
61
+
62
+ it 'throws ServerError if 500' do
63
+ response_double = instance_double(Faraday::Response, status: 500)
64
+
65
+ allow(connection_double).to receive(:run_request).and_return(response_double)
66
+
67
+ expect do
68
+ client.get_team_subscriptions(team_id, params)
69
+ end.to raise_error(Spearly::Auth::ServerError)
70
+ end
71
+
72
+ it 'throws ServiceUnavailableError if 503' do
73
+ response_double = instance_double(Faraday::Response, status: 503)
74
+
75
+ allow(connection_double).to receive(:run_request).and_return(response_double)
76
+
77
+ expect do
78
+ client.get_team_subscriptions(team_id, params)
79
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
80
+ end
81
+ end
82
+ end