frodo 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8f56d9927d67dbbd6ffd716c73efde55b370083
4
- data.tar.gz: bf09fc5ca9a219c6f6eb0593ef8e7890cbf240c6
3
+ metadata.gz: d4990d9c4a633bd34d89ad21e4b2dc22ce67403d
4
+ data.tar.gz: 49cf24c243adf8173b957b3b364e38a44d4d039d
5
5
  SHA512:
6
- metadata.gz: 9ee5bef44ae2d6ff783deea44efeb4b3a562471e02ad0ea1d2204c6d19a8a77509a36ad36faecc7449e15cddd923f2485628b59a7239ca0ae74f9bd6fb92a4ac
7
- data.tar.gz: 5a508d979808942225b9c68bcf1438aecff8404d90f3735f0d47caaff9a446c507d6ef80148d15b40838e9d5ce66350752175af407ffc586f30fa51a1e27d1fd
6
+ metadata.gz: 950fa068d71e394f5466260ce4c8dc187990882da04fae039c0bf7437527aa763497b751b1ec27d2640a5077aa175abe8a381817d09b060035502aa3a8b4783e
7
+ data.tar.gz: 9c61d5759570a975fa136a4f1c0399cbf88bbcb00edb0240c7d6b972f3840a8e7928b9325fa96e8a2cfda1364ae8d920c35e3c4544eb512b4dcd9e44e1ae83a9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.10.1
4
+
5
+ [Fixed] Warning on Error definitions
6
+
7
+ ## 0.10.0
8
+
9
+ [Breaking] New client was introduce. Uses Faraday and middlewares
10
+ Query.first and Query.count do not execute either. Return the query as a string to execute
11
+ Removed interface on EntitySet and Entity to make those more structural object for now
12
+ [New Feature] Support Query.find with selecting specific fields
13
+ Support Oauth token flow and refresh token callback
14
+ Support for passing a service definition in memory
15
+ New Primitive API for the client
16
+ [Fixes] guid properly serializing in a query
17
+
3
18
  ## 0.9.3
4
19
 
5
20
  * Fix broken stack traces in response errors
data/lib/frodo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Frodo
2
- VERSION = '0.10.0'
2
+ VERSION = '0.10.1'
3
3
  end
data/lib/frodo.rb CHANGED
@@ -34,7 +34,6 @@ require 'frodo/client'
34
34
  require 'frodo/config'
35
35
 
36
36
  require 'frodo/version'
37
- require 'frodo/errors'
38
37
  require 'frodo/property_registry'
39
38
  require 'frodo/property'
40
39
  require 'frodo/properties'
@@ -0,0 +1,456 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'json'
5
+
6
+ describe Frodo::Concerns::API do
7
+ let(:klass) do
8
+ context = self
9
+ Class.new {
10
+ include Frodo::Concerns::Base
11
+ include Frodo::Concerns::Connection
12
+
13
+ include context.described_class
14
+ }
15
+ end
16
+
17
+ let(:client) { klass.new }
18
+ let(:connection) {
19
+ Faraday.new('http://frodo.com', {}) do |conn|
20
+ conn.request :json
21
+ conn.response :json
22
+ conn.adapter Faraday.default_adapter
23
+ end
24
+ }
25
+
26
+ subject { client }
27
+
28
+ let(:id) { 'some-id' }
29
+ let(:body) { 'Body' }
30
+ let(:path) { 'something/foo' }
31
+ # Leverage WebMock match URI by pattern, needs to escape string otherwise chars like '$' are misinterpretted
32
+ let(:uri) { /#{Regexp.escape(path)}/ }
33
+ let(:options) { {} }
34
+ let(:verb) { :get }
35
+ let(:headers) { {} }
36
+ let(:entity_type) { 'Type' }
37
+ let(:entity_set) { double(Frodo::EntitySet) }
38
+ let(:entity) { double(Frodo::Entity) }
39
+ let(:service) { double(Frodo::Service) }
40
+ let(:query) { double(Frodo::Query) }
41
+ let(:client_error) { Faraday::Error::ClientError.new(StandardError.new) }
42
+
43
+ before do
44
+ stub_request(verb, uri).to_return(body: body.to_json, headers: headers)
45
+ allow(client).to receive(:options).and_return(options)
46
+ allow(client).to receive(:connection).and_return(connection)
47
+ end
48
+
49
+ describe '.metadata' do
50
+ let(:path) { '$metadata' }
51
+
52
+ it 'fetches body of GET $metadata' do
53
+ expect(subject.metadata).to eq(body)
54
+ end
55
+ end
56
+
57
+ describe '.query' do
58
+ let(:url_chunk) { "leads?$filter=firstname eq 'yo'" }
59
+ let(:path) { url_chunk }
60
+ let(:entity_name) { 'entity' }
61
+ let(:context) { "serviceRoot/$metadata##{entity_name}"}
62
+ let(:body) { { '@odata.context' => context } }
63
+
64
+ context 'url_chunk provided' do
65
+ let(:query) { url_chunk }
66
+
67
+ it 'returns entity fetched from url_chunk' do
68
+ allow(client).to receive(:build_entity).with(entity_name, body).and_return(entity)
69
+
70
+ expect(subject.query(query)).to eq(entity)
71
+ end
72
+ end
73
+
74
+ context 'Frodo::Query provided' do
75
+ let(:query) { double(Frodo::Query) }
76
+
77
+ it 'returns entity fetched from query' do
78
+ allow(query).to receive(:to_s).and_return(path)
79
+ allow(query).to receive(:entity_set).and_return(entity)
80
+ allow(entity).to receive(:name).and_return(entity_name)
81
+ allow(client).to receive(:build_entity).with(entity_name, body).and_return(entity)
82
+
83
+ expect(subject.query(query)).to eq(entity)
84
+ end
85
+ end
86
+ end
87
+
88
+ describe '.create' do
89
+ let(:attributes) { {} }
90
+
91
+ subject { client.create(entity_type, attributes) }
92
+
93
+ it 'calls .create! and returns the result' do
94
+ allow(client).to receive(:create!).with(entity_type, attributes).and_return(true)
95
+
96
+ expect(subject).to eq(true)
97
+ end
98
+
99
+ it 'returns false for expected exceptions' do
100
+ allow(client).to receive(:create!).with(entity_type, attributes).and_raise(client_error)
101
+
102
+ expect(subject).to eq(false)
103
+ end
104
+
105
+ it 'raises other errors' do
106
+ allow(client).to receive(:create!).with(entity_type, attributes).and_raise(StandardError)
107
+
108
+ expect{ subject }.to raise_error(StandardError)
109
+ end
110
+ end
111
+
112
+ describe '.create!' do
113
+ let(:id) { '(an-id)' }
114
+ let(:url) { "blah/#{id}/foo" }
115
+ let(:verb) { :post }
116
+ let(:attributes) { {} }
117
+ let(:options) { attributes }
118
+ let(:headers) { { 'odata-entityid' => url } }
119
+
120
+ subject { client.create!(entity_type, attributes) }
121
+
122
+ before do
123
+ allow(client).to receive(:service).and_return(service)
124
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
125
+ allow(entity_set).to receive(:new_entity).with(attributes).and_return(entity)
126
+ allow(client).to receive(:to_url_chunk).with(entity).and_return(path)
127
+ end
128
+
129
+ it 'posts entity_set info and returns resulting id' do
130
+ expect(subject).to eq(id)
131
+ end
132
+
133
+ it 'raises errors that occur' do
134
+ allow(client).to receive(:service).and_raise(StandardError)
135
+
136
+ expect{ subject }.to raise_error
137
+ end
138
+
139
+ context 'alias .insert!' do
140
+ subject { client.insert!(entity_type, attributes) }
141
+
142
+ it { should eq(id) }
143
+ end
144
+ end
145
+
146
+ describe '.update' do
147
+ let(:attributes) { {} }
148
+
149
+ subject { client.update(entity_type, attributes) }
150
+
151
+ it 'calls .create! and returns the result' do
152
+ allow(client).to receive(:update!).with(entity_type, attributes).and_return(true)
153
+
154
+ expect(subject).to be(true)
155
+ end
156
+
157
+ it 'returns false for expected exceptions' do
158
+ allow(client).to receive(:update!).with(entity_type, attributes).and_raise(client_error)
159
+
160
+ expect(subject).to eq(false)
161
+ end
162
+
163
+ it 'raises other errors' do
164
+ allow(client).to receive(:update!).with(entity_type, attributes).and_raise(StandardError)
165
+
166
+ expect{ subject }.to raise_error(StandardError)
167
+ end
168
+ end
169
+
170
+ describe '.update!' do
171
+ let(:verb) { :patch }
172
+ let(:attributes) { {} }
173
+ let(:options) { attributes }
174
+ let(:is_new) { false }
175
+
176
+ subject { client.update!(entity_type, attributes) }
177
+
178
+ before do
179
+ allow(client).to receive(:service).and_return(service)
180
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
181
+ allow(entity_set).to receive(:new_entity).with(attributes).and_return(entity)
182
+ allow(client).to receive(:to_url_chunk).with(entity).and_return(path)
183
+ allow(entity).to receive(:is_new?).and_return(is_new)
184
+ end
185
+
186
+ it 'posts entity_set info and returns true' do
187
+ expect(subject).to eq(true)
188
+ end
189
+
190
+ it 'raises errors that occur' do
191
+ allow(client).to receive(:service).and_raise(StandardError)
192
+
193
+ expect{ subject }.to raise_error(StandardError)
194
+ end
195
+
196
+ context 'new entity (ie. has no id)' do
197
+ let(:is_new) { true }
198
+
199
+ it 'raises ArgumentError' do
200
+ expect{ subject }.to raise_error(ArgumentError)
201
+ end
202
+ end
203
+ end
204
+
205
+ describe '.destroy' do
206
+
207
+ subject { client.destroy(entity_type, id) }
208
+
209
+ it 'calls .create! and returns true' do
210
+ allow(client).to receive(:destroy!).with(entity_type, id).and_return(true)
211
+
212
+ expect(subject).to be(true)
213
+ end
214
+
215
+ it 'returns false for expected exceptions' do
216
+ allow(client).to receive(:destroy!).with(entity_type, id).and_raise(client_error)
217
+
218
+ expect(subject).to eq(false)
219
+ end
220
+
221
+ it 'raises other errors' do
222
+ allow(client).to receive(:destroy!).with(entity_type, id).and_raise(StandardError)
223
+
224
+ expect{ subject }.to raise_error(StandardError)
225
+ end
226
+ end
227
+
228
+ describe '.destroy!' do
229
+ let(:verb) { :delete }
230
+
231
+ subject { client.destroy!(entity_type, id) }
232
+
233
+ it 'deletes entity_set and returns true' do
234
+ allow(client).to receive(:service).and_return(service)
235
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
236
+ allow(entity_set).to receive(:query).and_return(query)
237
+ allow(query).to receive(:find).with(id).and_return(path)
238
+
239
+ expect(subject).to eq(true)
240
+ end
241
+
242
+ it 'raises exceptions' do
243
+ allow(client).to receive(:service).and_raise(StandardError)
244
+
245
+ expect { subject }.to raise_error(StandardError)
246
+ end
247
+ end
248
+
249
+ describe '.find' do
250
+
251
+ subject { client.find(entity_type, id)}
252
+
253
+ it 'returns found entity_set' do
254
+ allow(client).to receive(:service).and_return(service)
255
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
256
+ allow(entity_set).to receive(:query).and_return(query)
257
+ allow(query).to receive(:find).with(id).and_return(path)
258
+ allow(client).to receive(:build_entity).with(entity_type, body).and_return(entity)
259
+
260
+ expect(subject).to eq(entity)
261
+ end
262
+
263
+ it 'raises any error that occurs' do
264
+ allow(client).to receive(:service).and_raise(StandardError)
265
+
266
+ expect { subject }.to raise_error(StandardError)
267
+ end
268
+ end
269
+
270
+ describe '.select' do
271
+ let(:fields) { ['field'] }
272
+
273
+ subject { client.select(entity_type, id, fields) }
274
+
275
+ it 'returns selected entity and fields' do
276
+ allow(client).to receive(:service).and_return(service)
277
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
278
+ allow(entity_set).to receive(:query).and_return(query)
279
+ allow(query).to receive(:find).and_return(path)
280
+ allow(client).to receive(:build_entity).with(entity_type, body).and_return(entity)
281
+
282
+ expect(query).to receive(:select).exactly(fields.count).times
283
+ expect(subject).to eq(entity)
284
+ end
285
+
286
+ it 'raises any error that occurs' do
287
+ allow(client).to receive(:service).and_raise(StandardError)
288
+
289
+ expect { subject }.to raise_error(StandardError)
290
+ end
291
+ end
292
+
293
+ describe '.count' do
294
+ let(:count) { 99 }
295
+ let(:body) { { '@odata.count' => count } }
296
+
297
+ subject { client.count(query) }
298
+
299
+ context 'provided a Frodo::Query' do
300
+
301
+ it 'uses query object to build count query and returns count' do
302
+ allow(query).to receive(:is_a?).with(Frodo::Query.class).and_return(true)
303
+ allow(query).to receive(:include_count)
304
+ allow(query).to receive(:to_s).and_return(path)
305
+
306
+ expect(subject).to eq(count.to_i)
307
+ end
308
+
309
+ it 'raises any error that occurs' do
310
+ allow(query).to receive(:is_a?).with(Frodo::Query.class).and_raise(StandardError)
311
+
312
+ expect{ subject }.to raise_error(StandardError)
313
+ end
314
+ end
315
+
316
+ context 'provided a string that is entity_type' do
317
+ let(:query) { entity_type }
318
+ let(:frodo_query) { double(Frodo::Query) }
319
+ let(:body) { count.to_s }
320
+
321
+ it 'makes count query and retuns count' do
322
+ allow(client).to receive(:service).and_return(service)
323
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
324
+ allow(entity_set).to receive(:query).and_return(frodo_query)
325
+ allow(frodo_query).to receive(:count).and_return(path)
326
+
327
+ expect(subject).to eq(count)
328
+ end
329
+
330
+ it 'raises any error that occurs' do
331
+ allow(client).to receive(:service).and_raise(StandardError)
332
+
333
+ expect{ subject }.to raise_error(StandardError)
334
+ end
335
+ end
336
+ end
337
+
338
+ # private methods
339
+
340
+ describe '.api_path' do
341
+
342
+ subject { client.send(:api_path, path) }
343
+
344
+ context 'base_path is defined' do
345
+ let(:options) { { base_path: path } }
346
+
347
+ it 'returns base_path + path' do
348
+ allow(client).to receive(:options).and_return(options)
349
+
350
+ expect(subject).to eq("#{path}/#{path}")
351
+ end
352
+ end
353
+
354
+ it { should eq "/#{path}" }
355
+ end
356
+
357
+ describe '.build_entity' do
358
+ let(:data) { 'data!!!!!' }
359
+
360
+ subject { client.send(:build_entity, entity_type, data) }
361
+
362
+ before do
363
+ allow(client).to receive(:service).and_return(service)
364
+ allow(service).to receive(:[]).with(entity_type).and_return(entity_set)
365
+ allow(entity_set).to receive(:entity_options).and_return(options)
366
+ end
367
+
368
+ it 'parses single entity' do
369
+ allow(client).to receive(:single_entity?).with(data).and_return(true)
370
+
371
+ expect(client).to receive(:parse_entity).with(data, options)
372
+ subject
373
+ end
374
+
375
+ context 'multiple entities' do
376
+ it 'parses multiple entities' do
377
+ allow(client).to receive(:single_entity?).with(data).and_return(false)
378
+
379
+ expect(client).to receive(:parse_entities).with(data, options)
380
+ subject
381
+ end
382
+ end
383
+ end
384
+
385
+ describe '.single_entity?' do
386
+ let(:body) { { '@odata.context' => '$entity' } }
387
+
388
+ subject { client.send(:single_entity?, body) }
389
+
390
+ it "returns true when context contains string '$entity'" do
391
+ expect(subject).to be_truthy
392
+ end
393
+
394
+ context "body context does not contain '$entity'" do
395
+ let(:body) { { '@odata.context' => 'other' } }
396
+
397
+ it { should be(nil) }
398
+ end
399
+ end
400
+
401
+ describe '.parse_entity' do
402
+ let(:entity_data) { {} }
403
+
404
+ subject { client.send(:parse_entity, entity_data, options) }
405
+
406
+ it 'builds Frodo::Entity' do
407
+ expect(Frodo::Entity).to receive(:from_json).with(entity_data, options)
408
+ subject
409
+ end
410
+ end
411
+
412
+ describe '.parse_entities' do
413
+ let(:entity_data) { "data!!!" }
414
+ let(:data_value) { [entity_data, entity_data] }
415
+ let(:data) { { 'value' => data_value } }
416
+
417
+ subject { client.send(:parse_entities, data, options) }
418
+
419
+ it 'builds Frodo::Entity from body value' do
420
+ expect(Frodo::Entity).to receive(:from_json).with(entity_data, options).exactly(data_value.count).times
421
+ subject
422
+ end
423
+ end
424
+
425
+ describe '.to_url_chunk' do
426
+ let(:primary_key) { "I am the key!" }
427
+ let(:property) { double() }
428
+ let(:set) { "Who am I?" }
429
+
430
+ subject { client.send(:to_url_chunk, entity) }
431
+
432
+ before do
433
+ allow(entity).to receive(:primary_key).and_return(primary_key)
434
+ allow(entity).to receive(:get_property).with(primary_key).and_return(property)
435
+ allow(property).to receive(:url_value).and_return(primary_key)
436
+ allow(entity).to receive(:entity_set).and_return(entity_set)
437
+ allow(entity_set).to receive(:name).and_return(set)
438
+ end
439
+
440
+ context 'entities with ids' do
441
+ it 'returns key composed with private key' do
442
+ allow(entity).to receive(:is_new?).and_return(false)
443
+
444
+ expect(subject).to eq("#{set}(#{primary_key})")
445
+ end
446
+ end
447
+
448
+ context 'new entities' do
449
+ it 'returns key composed without private key' do
450
+ allow(entity).to receive(:is_new?).and_return(true)
451
+
452
+ expect(subject).to eq(set)
453
+ end
454
+ end
455
+ end
456
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frodo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emmanuel Pinault
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-15 00:00:00.000000000 Z
11
+ date: 2019-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -262,7 +262,6 @@ files:
262
262
  - lib/frodo/entity.rb
263
263
  - lib/frodo/entity_container.rb
264
264
  - lib/frodo/entity_set.rb
265
- - lib/frodo/errors.rb
266
265
  - lib/frodo/middleware.rb
267
266
  - lib/frodo/middleware/authentication.rb
268
267
  - lib/frodo/middleware/authentication/token.rb
@@ -332,6 +331,7 @@ files:
332
331
  - spec/fixtures/refresh_error_response.json
333
332
  - spec/frodo/abstract_client_spec.rb
334
333
  - spec/frodo/client_spec.rb
334
+ - spec/frodo/concerns/api_spec.rb
335
335
  - spec/frodo/concerns/authentication_spec.rb
336
336
  - spec/frodo/concerns/base_spec.rb
337
337
  - spec/frodo/concerns/caching_spec.rb
@@ -341,7 +341,6 @@ files:
341
341
  - spec/frodo/entity_container_spec.rb
342
342
  - spec/frodo/entity_set_spec.rb
343
343
  - spec/frodo/entity_spec.rb
344
- - spec/frodo/errors_spec.rb
345
344
  - spec/frodo/middleware/authentication/token_spec.rb
346
345
  - spec/frodo/middleware/authentication_spec.rb
347
346
  - spec/frodo/middleware/authorization_spec.rb
@@ -425,6 +424,7 @@ test_files:
425
424
  - spec/fixtures/refresh_error_response.json
426
425
  - spec/frodo/abstract_client_spec.rb
427
426
  - spec/frodo/client_spec.rb
427
+ - spec/frodo/concerns/api_spec.rb
428
428
  - spec/frodo/concerns/authentication_spec.rb
429
429
  - spec/frodo/concerns/base_spec.rb
430
430
  - spec/frodo/concerns/caching_spec.rb
@@ -434,7 +434,6 @@ test_files:
434
434
  - spec/frodo/entity_container_spec.rb
435
435
  - spec/frodo/entity_set_spec.rb
436
436
  - spec/frodo/entity_spec.rb
437
- - spec/frodo/errors_spec.rb
438
437
  - spec/frodo/middleware/authentication/token_spec.rb
439
438
  - spec/frodo/middleware/authentication_spec.rb
440
439
  - spec/frodo/middleware/authorization_spec.rb
data/lib/frodo/errors.rb DELETED
@@ -1,70 +0,0 @@
1
- module Frodo
2
- # Base class for Frodo errors
3
- class Error < StandardError
4
- end
5
-
6
- # Base class for network errors
7
- class RequestError < Error
8
- attr_reader :response
9
-
10
- def initialize(response, message = nil)
11
- super(message)
12
- @message = message
13
- @response = response
14
- end
15
-
16
- def http_status
17
- response.status
18
- end
19
-
20
- def message
21
- [default_message, @message].compact.join(': ')
22
- end
23
-
24
- def default_message
25
- nil
26
- end
27
- end
28
-
29
- class ClientError < RequestError
30
- end
31
-
32
- class ServerError < RequestError
33
- end
34
-
35
- module Errors
36
- ERROR_MAP = []
37
-
38
- CLIENT_ERRORS = {
39
- 400 => "Bad Request",
40
- 401 => "Access Denied",
41
- 403 => "Forbidden",
42
- 404 => "Not Found",
43
- 405 => "Method Not Allowed",
44
- 406 => "Not Acceptable",
45
- 413 => "Request Entity Too Large",
46
- 415 => "Unsupported Media Type"
47
- }
48
-
49
- CLIENT_ERRORS.each do |code, message|
50
- klass = Class.new(ClientError) do
51
- send(:define_method, :default_message) { "#{code} #{message}" }
52
- end
53
- const_set(message.delete(' \-\''), klass)
54
- ERROR_MAP[code] = klass
55
- end
56
-
57
- SERVER_ERRORS = {
58
- 500 => "Internal Server Error",
59
- 503 => "Service Unavailable"
60
- }
61
-
62
- SERVER_ERRORS.each do |code, message|
63
- klass = Class.new(ServerError) do
64
- send(:define_method, :default_message) { "#{code} #{message}" }
65
- end
66
- const_set(message.delete(' \-\''), klass)
67
- ERROR_MAP[code] = klass
68
- end
69
- end
70
- end
@@ -1,48 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Frodo::RequestError do
4
- subject { Frodo::RequestError.new(response, 'The server made a boo-boo.') }
5
- let(:response) { instance_double('Faraday::Response', status: 400) }
6
-
7
- describe '#http_status' do
8
- it 'returns the status code' do
9
- expect(subject.http_status).to eq(response.status)
10
- end
11
- end
12
-
13
- describe '#response' do
14
- it 'returns the response' do
15
- expect(subject.response).to eq(response)
16
- end
17
- end
18
-
19
- describe '#message' do
20
- it 'returns the error message' do
21
- expect(subject.message).to eq('The server made a boo-boo.')
22
- end
23
- end
24
- end
25
-
26
- describe Frodo::Errors::InternalServerError do
27
- let(:response) { instance_double('Faraday::Response', status: 500) }
28
-
29
- context 'with custom error message' do
30
- subject { Frodo::Errors::InternalServerError.new(response, 'The server made a boo-boo.')}
31
-
32
- describe '#message' do
33
- it 'combines default message with custom message' do
34
- expect(subject.message).to eq('500 Internal Server Error: The server made a boo-boo.')
35
- end
36
- end
37
- end
38
-
39
- context 'without custom error message' do
40
- subject { Frodo::Errors::InternalServerError.new(response) }
41
-
42
- describe '#message' do
43
- it 'returns the default message' do
44
- expect(subject.message).to eq('500 Internal Server Error')
45
- end
46
- end
47
- end
48
- end