onfido 1.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +31 -0
  3. data/.github/workflows/ruby.yml +25 -0
  4. data/.rubocop.yml +5 -49
  5. data/.travis.yml +3 -10
  6. data/CHANGELOG.md +27 -0
  7. data/Gemfile +2 -0
  8. data/README.md +44 -156
  9. data/lib/onfido.rb +4 -3
  10. data/lib/onfido/api.rb +21 -11
  11. data/lib/onfido/errors/connection_error.rb +2 -0
  12. data/lib/onfido/errors/onfido_error.rb +2 -0
  13. data/lib/onfido/errors/request_error.rb +2 -0
  14. data/lib/onfido/errors/server_error.rb +2 -0
  15. data/lib/onfido/options.rb +38 -0
  16. data/lib/onfido/resource.rb +48 -58
  17. data/lib/onfido/resources/address.rb +3 -4
  18. data/lib/onfido/resources/applicant.rb +2 -0
  19. data/lib/onfido/resources/check.rb +6 -0
  20. data/lib/onfido/resources/document.rb +2 -0
  21. data/lib/onfido/resources/extraction.rb +11 -0
  22. data/lib/onfido/resources/live_photo.rb +2 -0
  23. data/lib/onfido/resources/live_video.rb +2 -0
  24. data/lib/onfido/resources/report.rb +2 -0
  25. data/lib/onfido/resources/sdk_token.rb +2 -0
  26. data/lib/onfido/resources/webhook.rb +8 -2
  27. data/lib/onfido/version.rb +3 -1
  28. data/onfido.gemspec +5 -7
  29. data/spec/integrations/address_spec.rb +4 -2
  30. data/spec/integrations/applicant_spec.rb +12 -7
  31. data/spec/integrations/check_spec.rb +17 -4
  32. data/spec/integrations/document_spec.rb +8 -4
  33. data/spec/integrations/extraction_spec.rb +23 -0
  34. data/spec/integrations/live_photo_spec.rb +8 -4
  35. data/spec/integrations/live_video_spec.rb +6 -1
  36. data/spec/integrations/report_spec.rb +6 -1
  37. data/spec/integrations/resource_spec.rb +106 -0
  38. data/spec/integrations/sdk_token_spec.rb +5 -1
  39. data/spec/integrations/webhook_spec.rb +35 -24
  40. data/spec/onfido/api_spec.rb +14 -25
  41. data/spec/onfido/connection_error_spec.rb +4 -2
  42. data/spec/onfido/options_spec.rb +39 -0
  43. data/spec/onfido/request_error_spec.rb +4 -2
  44. data/spec/spec_helper.rb +3 -5
  45. data/spec/support/fake_onfido_api.rb +69 -46
  46. data/spec/support/fixtures/applicant.json +1 -1
  47. data/spec/support/fixtures/check.json +1 -1
  48. data/spec/support/fixtures/checks.json +1 -1
  49. data/spec/support/fixtures/document.json +1 -1
  50. data/spec/support/fixtures/documents.json +2 -2
  51. data/spec/support/fixtures/extraction.json +23 -0
  52. data/spec/support/fixtures/live_photo.json +2 -2
  53. data/spec/support/fixtures/live_photos.json +4 -4
  54. data/spec/support/fixtures/live_video.json +2 -2
  55. data/spec/support/fixtures/live_videos.json +2 -2
  56. data/spec/support/fixtures/report.json +1 -1
  57. data/spec/support/fixtures/reports.json +2 -2
  58. data/spec/support/fixtures/webhook.json +1 -1
  59. data/spec/support/fixtures/webhooks.json +2 -2
  60. metadata +18 -43
  61. data/Rakefile +0 -1
  62. data/lib/onfido/configuration.rb +0 -46
  63. data/lib/onfido/null_logger.rb +0 -5
  64. data/spec/integrations/exceptions_spec.rb +0 -73
  65. data/spec/onfido/resource_spec.rb +0 -131
  66. data/spec/onfido_spec.rb +0 -76
@@ -4,6 +4,6 @@
4
4
  "file_name": "onfido_captured_image.jpg",
5
5
  "file_type": "image/jpeg",
6
6
  "file_size": 47544,
7
- "href": "/v3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
8
- "download_href": "/v3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
7
+ "href": "/v3.1/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
8
+ "download_href": "/v3.1/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
9
9
  }
@@ -6,8 +6,8 @@
6
6
  "file_name": "onfido_captured_image.jpg",
7
7
  "file_type": "image/jpeg",
8
8
  "file_size": 47544,
9
- "href": "/v3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
10
- "download_href": "/v3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
9
+ "href": "/v3.1/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
10
+ "download_href": "/v3.1/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
11
11
  },
12
12
  {
13
13
  "id": "5134c12a-555a-1234-5e12-9d34fcbc11ba",
@@ -15,8 +15,8 @@
15
15
  "file_name": "onfido_captured_image.jpg",
16
16
  "file_type": "image/jpeg",
17
17
  "file_size": 47544,
18
- "href": "/v3/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba",
19
- "download_href": "/v3/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba/download"
18
+ "href": "/v3.1/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba",
19
+ "download_href": "/v3.1/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba/download"
20
20
  }
21
21
  ]
22
22
  }
@@ -18,6 +18,6 @@
18
18
  "file_name" : "output-29-05-2018_11_00_24.mov",
19
19
  "file_type" : "video/quicktime",
20
20
  "file_size" : 3348421,
21
- "href" : "/v3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
22
- "download_href" : "/v3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download"
21
+ "href" : "/v3.1/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
22
+ "download_href" : "/v3.1/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download"
23
23
  }
@@ -16,11 +16,11 @@
16
16
  }
17
17
  ],
18
18
  "created_at": "2019-11-29T09:00:39Z",
19
- "download_href": "/v3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download",
19
+ "download_href": "/v3.1/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download",
20
20
  "file_name": "output-29-11-2019_11_00_24.mov",
21
21
  "file_size": 3348421,
22
22
  "file_type": "video/quicktime",
23
- "href": "/v3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
23
+ "href": "/v3.1/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
24
24
  "id": "c9701e9b-83aa-442f-995b-20320ee8fb01"
25
25
  }
26
26
  ]
@@ -4,7 +4,7 @@
4
4
  "created_at": "2019-11-23T13:50:45Z",
5
5
  "status": "in_progress",
6
6
  "result": "pending",
7
- "href": "/v3/reports/6951786-123123-422221",
7
+ "href": "/v3.1/reports/6951786-123123-422221",
8
8
  "breakdown": {},
9
9
  "properties": {}
10
10
  }
@@ -6,7 +6,7 @@
6
6
  "created_at": "2019-11-23T13:50:45Z",
7
7
  "status": "in_progress",
8
8
  "result": "pending",
9
- "href": "/v3/reports/6951786-123123-422221",
9
+ "href": "/v3.1/reports/6951786-123123-422221",
10
10
  "breakdown": {},
11
11
  "properties": {}
12
12
  },
@@ -16,7 +16,7 @@
16
16
  "created_at": "2019-11-23T13:50:45Z",
17
17
  "status": "in_progress",
18
18
  "result": "pending",
19
- "href": "/v3/reports/6951786-123123-316712",
19
+ "href": "/v3.1/reports/6951786-123123-316712",
20
20
  "breakdown": {},
21
21
  "properties": {}
22
22
  }
@@ -3,7 +3,7 @@
3
3
  "url": "https://webhookendpoint.url",
4
4
  "token": "yV85IsmuYwmjQGlZ",
5
5
  "enabled": true,
6
- "href": "/v3/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
6
+ "href": "/v3.1/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
7
7
  "environments": [
8
8
  "live"
9
9
  ],
@@ -4,7 +4,7 @@
4
4
  "id": "dd0a89e4-d44e-417a-aec4-01137d01ae59",
5
5
  "url": "https://demo.com",
6
6
  "enabled":false,
7
- "href": "/v3/webhooks/dd0a89e4-d44e-417a-aec4-01137d01ae59",
7
+ "href": "/v3.1/webhooks/dd0a89e4-d44e-417a-aec4-01137d01ae59",
8
8
  "environments": [
9
9
  "live"
10
10
  ],
@@ -18,7 +18,7 @@
18
18
  "id": "bfc727a8-f7bf-4073-b123-ed70a70f58e5",
19
19
  "url": "https://demo2.com",
20
20
  "enabled": true,
21
- "href": "/v3/webhooks/bfc727a8-f7bf-4073-b123-ed70a70f58e5",
21
+ "href": "/v3.1/webhooks/bfc727a8-f7bf-4073-b123-ed70a70f58e5",
22
22
  "environments": [
23
23
  "live"
24
24
  ],
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onfido
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onfido
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '12.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '12.0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: rspec
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +44,14 @@ dependencies:
72
44
  requirements:
73
45
  - - "~>"
74
46
  - !ruby/object:Gem::Version
75
- version: 0.57.0
47
+ version: '1.11'
76
48
  type: :development
77
49
  prerelease: false
78
50
  version_requirements: !ruby/object:Gem::Requirement
79
51
  requirements:
80
52
  - - "~>"
81
53
  - !ruby/object:Gem::Version
82
- version: 0.57.0
54
+ version: '1.11'
83
55
  - !ruby/object:Gem::Dependency
84
56
  name: sinatra
85
57
  requirement: !ruby/object:Gem::Requirement
@@ -145,6 +117,8 @@ executables: []
145
117
  extensions: []
146
118
  extra_rdoc_files: []
147
119
  files:
120
+ - ".github/workflows/gem-push.yml"
121
+ - ".github/workflows/ruby.yml"
148
122
  - ".gitignore"
149
123
  - ".rspec"
150
124
  - ".rubocop.yml"
@@ -153,20 +127,19 @@ files:
153
127
  - Gemfile
154
128
  - LICENSE
155
129
  - README.md
156
- - Rakefile
157
130
  - lib/onfido.rb
158
131
  - lib/onfido/api.rb
159
- - lib/onfido/configuration.rb
160
132
  - lib/onfido/errors/connection_error.rb
161
133
  - lib/onfido/errors/onfido_error.rb
162
134
  - lib/onfido/errors/request_error.rb
163
135
  - lib/onfido/errors/server_error.rb
164
- - lib/onfido/null_logger.rb
136
+ - lib/onfido/options.rb
165
137
  - lib/onfido/resource.rb
166
138
  - lib/onfido/resources/address.rb
167
139
  - lib/onfido/resources/applicant.rb
168
140
  - lib/onfido/resources/check.rb
169
141
  - lib/onfido/resources/document.rb
142
+ - lib/onfido/resources/extraction.rb
170
143
  - lib/onfido/resources/live_photo.rb
171
144
  - lib/onfido/resources/live_video.rb
172
145
  - lib/onfido/resources/report.rb
@@ -178,17 +151,17 @@ files:
178
151
  - spec/integrations/applicant_spec.rb
179
152
  - spec/integrations/check_spec.rb
180
153
  - spec/integrations/document_spec.rb
181
- - spec/integrations/exceptions_spec.rb
154
+ - spec/integrations/extraction_spec.rb
182
155
  - spec/integrations/live_photo_spec.rb
183
156
  - spec/integrations/live_video_spec.rb
184
157
  - spec/integrations/report_spec.rb
158
+ - spec/integrations/resource_spec.rb
185
159
  - spec/integrations/sdk_token_spec.rb
186
160
  - spec/integrations/webhook_spec.rb
187
161
  - spec/onfido/api_spec.rb
188
162
  - spec/onfido/connection_error_spec.rb
163
+ - spec/onfido/options_spec.rb
189
164
  - spec/onfido/request_error_spec.rb
190
- - spec/onfido/resource_spec.rb
191
- - spec/onfido_spec.rb
192
165
  - spec/spec_helper.rb
193
166
  - spec/support/fake_onfido_api.rb
194
167
  - spec/support/fixtures/4xx_response.json
@@ -199,6 +172,7 @@ files:
199
172
  - spec/support/fixtures/checks.json
200
173
  - spec/support/fixtures/document.json
201
174
  - spec/support/fixtures/documents.json
175
+ - spec/support/fixtures/extraction.json
202
176
  - spec/support/fixtures/live_photo.json
203
177
  - spec/support/fixtures/live_photos.json
204
178
  - spec/support/fixtures/live_video.json
@@ -222,14 +196,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
196
  requirements:
223
197
  - - ">="
224
198
  - !ruby/object:Gem::Version
225
- version: 2.2.0
199
+ version: 2.4.0
226
200
  required_rubygems_version: !ruby/object:Gem::Requirement
227
201
  requirements:
228
202
  - - ">="
229
203
  - !ruby/object:Gem::Version
230
204
  version: '0'
231
205
  requirements: []
232
- rubygems_version: 3.0.3
206
+ rubygems_version: 3.0.3.1
233
207
  signing_key:
234
208
  specification_version: 4
235
209
  summary: A wrapper for Onfido API
@@ -238,17 +212,17 @@ test_files:
238
212
  - spec/integrations/applicant_spec.rb
239
213
  - spec/integrations/check_spec.rb
240
214
  - spec/integrations/document_spec.rb
241
- - spec/integrations/exceptions_spec.rb
215
+ - spec/integrations/extraction_spec.rb
242
216
  - spec/integrations/live_photo_spec.rb
243
217
  - spec/integrations/live_video_spec.rb
244
218
  - spec/integrations/report_spec.rb
219
+ - spec/integrations/resource_spec.rb
245
220
  - spec/integrations/sdk_token_spec.rb
246
221
  - spec/integrations/webhook_spec.rb
247
222
  - spec/onfido/api_spec.rb
248
223
  - spec/onfido/connection_error_spec.rb
224
+ - spec/onfido/options_spec.rb
249
225
  - spec/onfido/request_error_spec.rb
250
- - spec/onfido/resource_spec.rb
251
- - spec/onfido_spec.rb
252
226
  - spec/spec_helper.rb
253
227
  - spec/support/fake_onfido_api.rb
254
228
  - spec/support/fixtures/4xx_response.json
@@ -259,6 +233,7 @@ test_files:
259
233
  - spec/support/fixtures/checks.json
260
234
  - spec/support/fixtures/document.json
261
235
  - spec/support/fixtures/documents.json
236
+ - spec/support/fixtures/extraction.json
262
237
  - spec/support/fixtures/live_photo.json
263
238
  - spec/support/fixtures/live_photos.json
264
239
  - spec/support/fixtures/live_video.json
data/Rakefile DELETED
@@ -1 +0,0 @@
1
- require 'bundler/gem_tasks'
@@ -1,46 +0,0 @@
1
- module Onfido
2
- module Configuration
3
- REGION_HOSTS = {
4
- us: "api.us.onfido.com"
5
- }.freeze
6
-
7
- attr_accessor :api_key, :region, :open_timeout, :read_timeout
8
-
9
- def self.extended(base)
10
- base.reset
11
- end
12
-
13
- def configure
14
- yield self
15
- end
16
-
17
- def reset
18
- self.api_key = nil
19
- self.region = nil
20
- self.open_timeout = 30
21
- self.read_timeout = 80
22
- RestClient.log = nil
23
- end
24
-
25
- def logger=(log)
26
- unless log.respond_to?(:<<)
27
- raise "#{log.class} doesn't seem to behave like a logger!"
28
- end
29
-
30
- RestClient.log = log
31
- end
32
-
33
- def logger
34
- RestClient.log ||= NullLogger.new
35
- end
36
-
37
- def endpoint
38
- region_host = region ? REGION_HOSTS[region.downcase.to_sym] : "api.onfido.com"
39
- unless region_host
40
- raise "The region \"#{region.downcase}\" is not currently supported"
41
- end
42
-
43
- "https://#{region_host}/v3/"
44
- end
45
- end
46
- end
@@ -1,5 +0,0 @@
1
- module Onfido
2
- class NullLogger
3
- def <<(*args); end
4
- end
5
- end
@@ -1,73 +0,0 @@
1
- describe Onfido::Resource do
2
- let(:resource) { described_class.new }
3
- let(:api_key) { 'some_key' }
4
- let(:payload) { { postcode: 'SE1 4NG' } }
5
-
6
- before { allow(Onfido).to receive(:api_key).and_return(api_key) }
7
-
8
- context '4xx response' do
9
- it 'raises a custom error' do
10
- path = '4xx_response'
11
-
12
- expect { resource.get(path: path, payload: payload) }.
13
- to raise_error(Onfido::RequestError, 'Something went wrong')
14
- end
15
- end
16
-
17
- context 'unexpected error format' do
18
- it 'raises a custom error' do
19
- path = 'unexpected_error_format'
20
-
21
- expect { resource.get(path: path, payload: payload) }.
22
- to raise_error(Onfido::RequestError, /response code was 400/)
23
- end
24
- end
25
-
26
- context 'unparseable JSON 5xx' do
27
- it 'raises a server error' do
28
- path = 'unparseable_response'
29
-
30
- expect { resource.get(path: path, payload: payload) }.
31
- to raise_error(Onfido::ServerError, /response code was 504/)
32
- end
33
- end
34
-
35
- context 'timeout' do
36
- before do
37
- allow(RestClient::Request).
38
- to receive(:execute).
39
- and_raise(RestClient::RequestTimeout)
40
- end
41
-
42
- it 'raises a ConnectionError' do
43
- expect { resource.get(path: Onfido.endpoint, payload: payload) }.
44
- to raise_error(Onfido::ConnectionError, /Could not connect/)
45
- end
46
- end
47
-
48
- context 'broken connection' do
49
- before do
50
- allow(RestClient::Request).
51
- to receive(:execute).
52
- and_raise(RestClient::ServerBrokeConnection)
53
- end
54
-
55
- it 'raises a ConnectionError' do
56
- expect { resource.get(path: Onfido.endpoint, payload: payload) }.
57
- to raise_error(Onfido::ConnectionError, /connection to the server/)
58
- end
59
- end
60
-
61
- context "bad SSL certificate" do
62
- before do
63
- allow(RestClient::Request).
64
- to receive(:execute).
65
- and_raise(RestClient::SSLCertificateNotVerified.new(nil))
66
- end
67
-
68
- it 'raises a ConnectionError' do
69
- expect { resource.get(path: Onfido.endpoint, payload: payload) }.
70
- to raise_error(Onfido::ConnectionError, /SSL certificate/)
71
- end
72
- end
73
- end
@@ -1,131 +0,0 @@
1
- require 'onfido/errors/connection_error'
2
-
3
- describe Onfido::Resource do
4
- subject(:resource) { described_class.new }
5
-
6
- let(:endpoint) { 'https://api.onfido.com/v3/' }
7
- let(:path) { 'addresses/pick' }
8
- let(:url) { endpoint + path }
9
- let(:payload) { { postcode: 'SE1 4NG' } }
10
- let(:api_key) { 'some_key' }
11
-
12
- let(:response) do
13
- {
14
- 'addresses' => [
15
- {
16
- 'street' => 'Main Street',
17
- 'town' => 'London',
18
- 'postcode' => 'SW4 6EH',
19
- 'country' => 'GBR'
20
- }
21
- ]
22
- }
23
- end
24
-
25
- before { allow(Onfido).to receive(:endpoint).and_return(endpoint) }
26
- before { allow(Onfido).to receive(:api_key).and_return(api_key) }
27
-
28
- describe '#method_missing' do
29
- %i(patch).each do |method|
30
- context "for unsupported HTTP method: #{method}" do
31
- it 'raises an error' do
32
- expect do
33
- resource.public_send(method, path: endpoint)
34
- end.to raise_error(NoMethodError)
35
- end
36
- end
37
- end
38
- end
39
-
40
- describe "API key" do
41
- subject(:resource) { described_class.new(specific_api_key) }
42
-
43
- before do
44
- expect(RestClient::Request).to receive(:execute).with(
45
- url: url,
46
- payload: Rack::Utils.build_query(payload),
47
- method: :get,
48
- headers: resource.send(:headers),
49
- open_timeout: 30,
50
- timeout: 80
51
- ).and_call_original
52
-
53
- WebMock.stub_request(:get, url).
54
- to_return(body: response.to_json, status: 200)
55
- end
56
-
57
- context "when using a specific key" do
58
- let(:specific_api_key) { "specific_key" }
59
-
60
- it "uses that key when making the request" do
61
- resource.get(path: path, payload: payload)
62
-
63
- expect(WebMock).to have_requested(:get, url).with(
64
- headers: {
65
- 'Authorization' => "Token token=#{specific_api_key}",
66
- 'Accept' => "application/json"
67
- }
68
- )
69
- end
70
- end
71
-
72
- context "when not using a specific key" do
73
- let(:specific_api_key) { nil }
74
-
75
- it "uses the general config key when making the request" do
76
- resource.get(path: path, payload: payload)
77
-
78
- expect(WebMock).to have_requested(:get, url).with(
79
- headers: {
80
- 'Authorization' => "Token token=#{api_key}",
81
- 'Accept' => "application/json"
82
- }
83
- )
84
- end
85
- end
86
- end
87
-
88
- describe "valid http methods" do
89
- %i(get post put delete).each do |method|
90
- context "for supported HTTP method: #{method}" do
91
- context "with a success response" do
92
- before do
93
- expect(RestClient::Request).to receive(:execute).
94
- with(
95
- url: url,
96
- payload: Rack::Utils.build_query(payload),
97
- method: method,
98
- headers: resource.send(:headers),
99
- open_timeout: 30,
100
- timeout: 80
101
- ).and_call_original
102
-
103
- WebMock.stub_request(method, url).
104
- to_return(body: response.to_json,
105
- status: 200,
106
- headers: { "Content-Type" => "application/json" })
107
- end
108
-
109
- it 'makes a request to an endpoint' do
110
- expect(resource.public_send(method, path: path, payload: payload)).
111
- to eq(response)
112
- end
113
- end
114
-
115
- context "with a timeout error response" do
116
- before do
117
- allow_any_instance_of(RestClient::ExceptionWithResponse).
118
- to receive(:response).and_return(double(body: "", code: "408"))
119
- expect(RestClient::Request).to receive(:execute).
120
- and_raise(RestClient::ExceptionWithResponse)
121
- end
122
-
123
- it "raises a ConnectionError" do
124
- expect { resource.public_send(method, path: path, payload: payload) }.
125
- to raise_error(Onfido::ConnectionError)
126
- end
127
- end
128
- end
129
- end
130
- end
131
- end