onfido 0.14.0 → 1.1.1
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/.rubocop.yml +4 -0
- data/.travis.yml +3 -7
- data/CHANGELOG.md +21 -0
- data/LICENSE +2 -1
- data/README.md +59 -73
- data/lib/onfido.rb +1 -1
- data/lib/onfido/api.rb +4 -4
- data/lib/onfido/configuration.rb +4 -4
- data/lib/onfido/resource.rb +3 -6
- data/lib/onfido/resources/address.rb +1 -4
- data/lib/onfido/resources/applicant.rb +6 -6
- data/lib/onfido/resources/check.rb +10 -14
- data/lib/onfido/resources/document.rb +11 -11
- data/lib/onfido/resources/extraction.rb +9 -0
- data/lib/onfido/resources/live_photo.rb +9 -14
- data/lib/onfido/resources/live_video.rb +5 -8
- data/lib/onfido/resources/report.rb +8 -9
- data/lib/onfido/resources/sdk_token.rb +3 -5
- data/lib/onfido/resources/webhook.rb +11 -9
- data/lib/onfido/version.rb +1 -1
- data/onfido.gemspec +6 -7
- data/spec/integrations/address_spec.rb +1 -0
- data/spec/integrations/applicant_spec.rb +21 -37
- data/spec/integrations/check_spec.rb +13 -23
- data/spec/integrations/document_spec.rb +16 -17
- data/spec/integrations/exceptions_spec.rb +12 -14
- data/spec/integrations/extraction_spec.rb +19 -0
- data/spec/integrations/live_photo_spec.rb +12 -13
- data/spec/integrations/live_video_spec.rb +7 -10
- data/spec/integrations/report_spec.rb +11 -13
- data/spec/integrations/sdk_token_spec.rb +5 -5
- data/spec/integrations/webhook_spec.rb +35 -20
- data/spec/onfido/resource_spec.rb +10 -14
- data/spec/onfido_spec.rb +9 -10
- data/spec/support/fake_onfido_api.rb +53 -78
- data/spec/support/fixtures/applicant.json +21 -42
- data/spec/support/fixtures/check.json +4 -4
- data/spec/support/fixtures/checks.json +4 -4
- data/spec/support/fixtures/document.json +2 -2
- data/spec/support/fixtures/documents.json +8 -8
- data/spec/support/fixtures/extraction.json +23 -0
- data/spec/support/fixtures/live_photo.json +3 -3
- data/spec/support/fixtures/live_photos.json +6 -6
- data/spec/support/fixtures/live_video.json +3 -3
- data/spec/support/fixtures/live_videos.json +4 -4
- data/spec/support/fixtures/not_scheduled_for_deletion_error.json +7 -0
- data/spec/support/fixtures/report.json +4 -4
- data/spec/support/fixtures/reports.json +8 -8
- data/spec/support/fixtures/webhook.json +6 -5
- data/spec/support/fixtures/webhooks.json +17 -12
- metadata +19 -40
- data/lib/onfido/resources/report_type_group.rb +0 -11
- data/spec/integrations/report_type_group_spec.rb +0 -19
- data/spec/support/fixtures/check_with_expanded_reports.json +0 -30
- data/spec/support/fixtures/checks_with_expanded_reports.json +0 -34
- data/spec/support/fixtures/report_type_group.json +0 -25
- data/spec/support/fixtures/report_type_groups.json +0 -30
@@ -6,15 +6,15 @@ describe Onfido::Document do
|
|
6
6
|
describe '#create' do
|
7
7
|
let(:params) do
|
8
8
|
{
|
9
|
-
|
10
|
-
|
11
|
-
file: file
|
9
|
+
applicant_id: '1030303-123123-123123',
|
10
|
+
type: 'driving_licence',
|
11
|
+
file: file,
|
12
|
+
side: 'front'
|
12
13
|
}
|
13
14
|
end
|
14
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
15
15
|
|
16
16
|
context 'with a File-like object to upload' do
|
17
|
-
let(:file) { Tempfile.new(['
|
17
|
+
let(:file) { Tempfile.new(['driving_licence', '.jpg']) }
|
18
18
|
|
19
19
|
after do
|
20
20
|
file.close
|
@@ -22,7 +22,8 @@ describe Onfido::Document do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'creates a new document' do
|
25
|
-
response = document.create(
|
25
|
+
response = document.create(**params)
|
26
|
+
|
26
27
|
expect(response['id']).not_to be_nil
|
27
28
|
end
|
28
29
|
end
|
@@ -31,37 +32,35 @@ describe Onfido::Document do
|
|
31
32
|
let(:file) { 'https://onfido.com/images/logo.png' }
|
32
33
|
|
33
34
|
it 'raises an ArgumentError' do
|
34
|
-
expect { document.create(
|
35
|
+
expect { document.create(**params) }.
|
35
36
|
to raise_error(ArgumentError, /must be a `File`-like object/)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
end
|
39
40
|
|
40
41
|
describe '#find' do
|
41
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
42
|
-
let(:document_id) { '7568415-123123-123123' }
|
43
|
-
|
44
42
|
it 'returns the expected document' do
|
45
|
-
|
43
|
+
document_id = '7568415-123123-123123'
|
44
|
+
response = document.find(document_id)
|
45
|
+
|
46
46
|
expect(response['id']).to eq(document_id)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#all' do
|
51
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
52
|
-
|
53
51
|
it 'returns list of documents' do
|
52
|
+
applicant_id = '1030303-123123-123123'
|
54
53
|
response = document.all(applicant_id)
|
54
|
+
|
55
55
|
expect(response['documents']).not_to be_empty
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe '#download' do
|
60
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
61
|
-
let(:document_id) { '1212121-123123-123123' }
|
62
|
-
|
63
60
|
it 'returns the file data' do
|
64
|
-
|
61
|
+
document_id = '1212121-123123-123123'
|
62
|
+
response = document.download(document_id)
|
63
|
+
|
65
64
|
expect(response).not_to be_nil
|
66
65
|
end
|
67
66
|
end
|
@@ -1,34 +1,32 @@
|
|
1
1
|
describe Onfido::Resource do
|
2
2
|
let(:resource) { described_class.new }
|
3
|
-
let(:url) { Onfido.endpoint + path }
|
4
3
|
let(:api_key) { 'some_key' }
|
5
|
-
let(:payload) { { postcode: 'SE1 4NG' } }
|
6
4
|
|
7
5
|
before { allow(Onfido).to receive(:api_key).and_return(api_key) }
|
8
6
|
|
9
7
|
context '4xx response' do
|
10
|
-
let(:path) { '4xx_response' }
|
11
|
-
|
12
8
|
it 'raises a custom error' do
|
13
|
-
|
9
|
+
path = '4xx_response'
|
10
|
+
|
11
|
+
expect { resource.get(path: path) }.
|
14
12
|
to raise_error(Onfido::RequestError, 'Something went wrong')
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
16
|
context 'unexpected error format' do
|
19
|
-
let(:path) { 'unexpected_error_format' }
|
20
|
-
|
21
17
|
it 'raises a custom error' do
|
22
|
-
|
18
|
+
path = 'unexpected_error_format'
|
19
|
+
|
20
|
+
expect { resource.get(path: path) }.
|
23
21
|
to raise_error(Onfido::RequestError, /response code was 400/)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
27
25
|
context 'unparseable JSON 5xx' do
|
28
|
-
let(:path) { 'unparseable_response' }
|
29
|
-
|
30
26
|
it 'raises a server error' do
|
31
|
-
|
27
|
+
path = 'unparseable_response'
|
28
|
+
|
29
|
+
expect { resource.get(path: path) }.
|
32
30
|
to raise_error(Onfido::ServerError, /response code was 504/)
|
33
31
|
end
|
34
32
|
end
|
@@ -41,7 +39,7 @@ describe Onfido::Resource do
|
|
41
39
|
end
|
42
40
|
|
43
41
|
it 'raises a ConnectionError' do
|
44
|
-
expect { resource.get(
|
42
|
+
expect { resource.get(path: Onfido.endpoint) }.
|
45
43
|
to raise_error(Onfido::ConnectionError, /Could not connect/)
|
46
44
|
end
|
47
45
|
end
|
@@ -54,7 +52,7 @@ describe Onfido::Resource do
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'raises a ConnectionError' do
|
57
|
-
expect { resource.get(
|
55
|
+
expect { resource.get(path: Onfido.endpoint) }.
|
58
56
|
to raise_error(Onfido::ConnectionError, /connection to the server/)
|
59
57
|
end
|
60
58
|
end
|
@@ -67,7 +65,7 @@ describe Onfido::Resource do
|
|
67
65
|
end
|
68
66
|
|
69
67
|
it 'raises a ConnectionError' do
|
70
|
-
expect { resource.get(
|
68
|
+
expect { resource.get(path: Onfido.endpoint) }.
|
71
69
|
to raise_error(Onfido::ConnectionError, /SSL certificate/)
|
72
70
|
end
|
73
71
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
describe Onfido::Extraction do
|
4
|
+
subject(:extraction) { described_class.new }
|
5
|
+
|
6
|
+
describe '#create' do
|
7
|
+
let(:params) do
|
8
|
+
{
|
9
|
+
document_id: '7568415-123123-123123'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'creates a new extraction' do
|
14
|
+
response = extraction.create(params)
|
15
|
+
|
16
|
+
expect(response['document_id']).to eq('7568415-123123-123123')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -4,7 +4,7 @@ describe Onfido::LivePhoto do
|
|
4
4
|
subject(:live_photo) { described_class.new }
|
5
5
|
|
6
6
|
describe '#create' do
|
7
|
-
let(:params) { { file: file } }
|
7
|
+
let(:params) { { applicant_id: '123456', file: file } }
|
8
8
|
|
9
9
|
context 'with a File-like object to upload' do
|
10
10
|
let(:file) { Tempfile.new(['passport', '.jpg']) }
|
@@ -15,7 +15,8 @@ describe Onfido::LivePhoto do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'creates a new photo' do
|
18
|
-
response = live_photo.create(
|
18
|
+
response = live_photo.create(**params)
|
19
|
+
|
19
20
|
expect(response['id']).not_to be_nil
|
20
21
|
end
|
21
22
|
end
|
@@ -24,37 +25,35 @@ describe Onfido::LivePhoto do
|
|
24
25
|
let(:file) { 'https://onfido.com/images/photo.jpg' }
|
25
26
|
|
26
27
|
it 'raises an ArgumentError' do
|
27
|
-
expect { live_photo.create(
|
28
|
+
expect { live_photo.create(**params) }.
|
28
29
|
to raise_error(ArgumentError, /must be a `File`-like object/)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
describe '#find' do
|
34
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
35
|
-
let(:live_photo_id) { '3538c8f6-fdce-4745-9d34-fc246bc05aa1' }
|
36
|
-
|
37
35
|
it 'returns the expected live photo' do
|
38
|
-
|
36
|
+
live_photo_id = '3538c8f6-fdce-4745-9d34-fc246bc05aa1'
|
37
|
+
response = live_photo.find(live_photo_id)
|
38
|
+
|
39
39
|
expect(response['id']).to eq(live_photo_id)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#all' do
|
44
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
45
|
-
|
46
44
|
it 'returns list of documents' do
|
45
|
+
applicant_id = '1030303-123123-123123'
|
47
46
|
response = live_photo.all(applicant_id)
|
47
|
+
|
48
48
|
expect(response['live_photos']).not_to be_empty
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe '#download' do
|
53
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
54
|
-
let(:live_photo_id) { '3538c8f6-fdce-4745-9d34-fc246bc05aa1' }
|
55
|
-
|
56
53
|
it 'returns the file data' do
|
57
|
-
|
54
|
+
live_photo_id = '3538c8f6-fdce-4745-9d34-fc246bc05aa1'
|
55
|
+
response = live_photo.download(live_photo_id)
|
56
|
+
|
58
57
|
expect(response).not_to be_nil
|
59
58
|
end
|
60
59
|
end
|
@@ -2,32 +2,29 @@ require 'tempfile'
|
|
2
2
|
|
3
3
|
describe Onfido::LiveVideo do
|
4
4
|
subject(:live_video) { described_class.new }
|
5
|
+
let(:live_video_id) { 'c9701e9b-83aa-442f-995b-20320ee8fb01' }
|
5
6
|
|
6
7
|
describe '#find' do
|
7
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
8
|
-
let(:live_video_id) { 'c9701e9b-83aa-442f-995b-20320ee8fb01' }
|
9
|
-
|
10
8
|
it 'returns the expected live photo' do
|
11
|
-
response = live_video.find(
|
9
|
+
response = live_video.find(live_video_id)
|
10
|
+
|
12
11
|
expect(response['id']).to eq(live_video_id)
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
describe '#all' do
|
17
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
18
|
-
|
19
16
|
it 'returns list of documents' do
|
17
|
+
applicant_id = '1030303-123123-123123'
|
20
18
|
response = live_video.all(applicant_id)
|
19
|
+
|
21
20
|
expect(response['live_videos']).not_to be_empty
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
describe '#download' do
|
26
|
-
let(:applicant_id) { '1030303-123123-123123' }
|
27
|
-
let(:live_video_id) { 'c9701e9b-83aa-442f-995b-20320ee8fb01' }
|
28
|
-
|
29
25
|
it 'returns the file data' do
|
30
|
-
response = live_video.download(
|
26
|
+
response = live_video.download(live_video_id)
|
27
|
+
|
31
28
|
expect(response).not_to be_nil
|
32
29
|
end
|
33
30
|
end
|
@@ -1,38 +1,36 @@
|
|
1
1
|
describe Onfido::Report do
|
2
2
|
subject(:report) { described_class.new }
|
3
|
-
let(:check_id) { '8546921-123123-123123' }
|
4
|
-
|
5
3
|
describe '#find' do
|
6
|
-
let(:report_id) { '6951786-123123-422221' }
|
7
|
-
|
8
4
|
it 'returns a report for an existing check' do
|
9
|
-
|
5
|
+
report_id = '6951786-123123-422221'
|
6
|
+
response = report.find(report_id)
|
7
|
+
|
10
8
|
expect(response['id']).to eq(report_id)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
14
12
|
describe '#all' do
|
15
13
|
it 'lists all reports for an existing check' do
|
14
|
+
check_id = '8546921-123123-123123'
|
16
15
|
response = report.all(check_id)
|
16
|
+
|
17
17
|
expect(response['reports'].count).to eq(2)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
describe '#resume' do
|
22
|
-
let(:report_id) { '6951786-123123-422221' }
|
23
|
-
let(:check_id) { '1212121-123123-422221' }
|
24
|
-
|
25
22
|
it 'returns a success response' do
|
26
|
-
|
23
|
+
report_id = '6951786-123123-422221'
|
24
|
+
|
25
|
+
expect { report.resume(report_id) }.not_to raise_error
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
29
|
describe '#cancel' do
|
31
|
-
let(:report_id) { '6951786-123123-422221' }
|
32
|
-
let(:check_id) { '1212121-123123-422221' }
|
33
|
-
|
34
30
|
it 'returns a success response' do
|
35
|
-
|
31
|
+
report_id = '6951786-123123-422221'
|
32
|
+
|
33
|
+
expect { report.cancel(report_id) }.not_to raise_error
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
describe Onfido::SdkToken do
|
2
2
|
subject(:sdk_token) { described_class.new }
|
3
|
-
let(:applicant_id) { '61f659cb-c90b-4067-808a-6136b5c01351' }
|
4
|
-
let(:referrer) { 'http://*.mywebsite.com/*' }
|
5
3
|
|
6
4
|
describe '#create' do
|
7
|
-
let(:params) { { applicant_id: applicant_id, referrer: referrer } }
|
8
|
-
|
9
5
|
it 'creates a new SDK token for the applicant' do
|
10
|
-
|
6
|
+
applicant_id = '61f659cb-c90b-4067-808a-6136b5c01351'
|
7
|
+
referrer = 'http://*.mywebsite.com/*'
|
8
|
+
|
9
|
+
response = sdk_token.create(applicant_id: applicant_id, referrer: referrer)
|
10
|
+
|
11
11
|
expect(response['token']).not_to be_nil
|
12
12
|
end
|
13
13
|
end
|
@@ -1,47 +1,58 @@
|
|
1
1
|
describe Onfido::Webhook do
|
2
2
|
subject(:webhook) { described_class.new }
|
3
|
-
let(:params) do
|
4
|
-
{
|
5
|
-
"url" => "https://webhookendpoint.url",
|
6
|
-
"enabled" => true,
|
7
|
-
"events" => [
|
8
|
-
"report completion",
|
9
|
-
"report withdrawal",
|
10
|
-
"check completion",
|
11
|
-
"check in progress"
|
12
|
-
]
|
13
|
-
}
|
14
|
-
end
|
15
3
|
|
16
4
|
describe "#create" do
|
17
|
-
|
18
|
-
|
5
|
+
let(:params) do
|
6
|
+
{
|
7
|
+
url: "https://webhookendpoint.url",
|
8
|
+
enabled: true,
|
9
|
+
events: [
|
10
|
+
"report.completed",
|
11
|
+
"check.completed"
|
12
|
+
]
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
it "creates the webhook" do
|
17
|
+
response = webhook.create(**params)
|
18
|
+
|
19
19
|
expect(response['id']).to_not be_nil
|
20
20
|
end
|
21
21
|
|
22
22
|
it "responds with the right url" do
|
23
|
-
response = webhook.create(params)
|
24
|
-
|
23
|
+
response = webhook.create(**params)
|
24
|
+
|
25
|
+
expect(response["url"]).to eq params[:url]
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
describe '#find' do
|
29
|
-
let(:webhook_id) { 'fcb73186-0733-4f6f-9c57-d9d5ef979443' }
|
30
|
-
|
31
30
|
it 'returns the webhook' do
|
31
|
+
webhook_id = 'fcb73186-0733-4f6f-9c57-d9d5ef979443'
|
32
|
+
|
32
33
|
response = webhook.find(webhook_id)
|
34
|
+
|
33
35
|
expect(response['id']).to eq(webhook_id)
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
39
|
+
describe "#destroy" do
|
40
|
+
it "removes the webhook" do
|
41
|
+
webhook_id = 'fcb73186-0733-4f6f-9c57-d9d5ef979443'
|
42
|
+
expect { webhook.destroy(webhook_id) }.not_to raise_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
37
46
|
describe "#all" do
|
38
47
|
it "returns all the registered webhooks" do
|
39
48
|
response = webhook.all
|
49
|
+
|
40
50
|
expect(response["webhooks"].count).to eq 2
|
41
51
|
end
|
42
52
|
|
43
53
|
it "returns with id" do
|
44
54
|
response = webhook.all
|
55
|
+
|
45
56
|
expect(response["webhooks"][0]["id"]).to_not be_nil
|
46
57
|
expect(response["webhooks"][1]["id"]).to_not be_nil
|
47
58
|
end
|
@@ -53,13 +64,17 @@ describe Onfido::Webhook do
|
|
53
64
|
end
|
54
65
|
|
55
66
|
let(:request_body) { '{"foo":"bar"}' }
|
56
|
-
let(:request_signature)
|
67
|
+
let(:request_signature) do
|
68
|
+
'89e60408fec20bfb26bb0f993d5e88307818982f50f23b361a00d679bae8b1dc'
|
69
|
+
end
|
57
70
|
let(:token) { 'very_secret_token' }
|
58
71
|
|
59
72
|
it { is_expected.to be(true) }
|
60
73
|
|
61
74
|
context "with an invalid signature" do
|
62
|
-
let(:request_signature)
|
75
|
+
let(:request_signature) do
|
76
|
+
's21fd54ew2w1f5d15642132f3d7727ff9a32a7c87072ce514df1f6d3228bec'
|
77
|
+
end
|
63
78
|
it { is_expected.to be(false) }
|
64
79
|
end
|
65
80
|
|
@@ -3,7 +3,7 @@ require 'onfido/errors/connection_error'
|
|
3
3
|
describe Onfido::Resource do
|
4
4
|
subject(:resource) { described_class.new }
|
5
5
|
|
6
|
-
let(:endpoint) { 'https://api.onfido.com/
|
6
|
+
let(:endpoint) { 'https://api.onfido.com/v3/' }
|
7
7
|
let(:path) { 'addresses/pick' }
|
8
8
|
let(:url) { endpoint + path }
|
9
9
|
let(:payload) { { postcode: 'SE1 4NG' } }
|
@@ -25,18 +25,12 @@ describe Onfido::Resource do
|
|
25
25
|
before { allow(Onfido).to receive(:endpoint).and_return(endpoint) }
|
26
26
|
before { allow(Onfido).to receive(:api_key).and_return(api_key) }
|
27
27
|
|
28
|
-
describe '#url_for' do
|
29
|
-
it 'composes the full api url' do
|
30
|
-
expect(resource.url_for(path)).to eq(endpoint + path)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
28
|
describe '#method_missing' do
|
35
29
|
%i(patch).each do |method|
|
36
30
|
context "for unsupported HTTP method: #{method}" do
|
37
31
|
it 'raises an error' do
|
38
32
|
expect do
|
39
|
-
resource.public_send(method,
|
33
|
+
resource.public_send(method, path: endpoint)
|
40
34
|
end.to raise_error(NoMethodError)
|
41
35
|
end
|
42
36
|
end
|
@@ -64,12 +58,13 @@ describe Onfido::Resource do
|
|
64
58
|
let(:specific_api_key) { "specific_key" }
|
65
59
|
|
66
60
|
it "uses that key when making the request" do
|
67
|
-
resource.get(
|
61
|
+
resource.get(path: path, payload: payload)
|
68
62
|
|
69
63
|
expect(WebMock).to have_requested(:get, url).with(
|
70
64
|
headers: {
|
71
65
|
'Authorization' => "Token token=#{specific_api_key}",
|
72
|
-
'Accept' => "application/json"
|
66
|
+
'Accept' => "application/json",
|
67
|
+
'User-Agent' => "onfido-ruby/#{Onfido::VERSION}"
|
73
68
|
}
|
74
69
|
)
|
75
70
|
end
|
@@ -79,12 +74,13 @@ describe Onfido::Resource do
|
|
79
74
|
let(:specific_api_key) { nil }
|
80
75
|
|
81
76
|
it "uses the general config key when making the request" do
|
82
|
-
resource.get(
|
77
|
+
resource.get(path: path, payload: payload)
|
83
78
|
|
84
79
|
expect(WebMock).to have_requested(:get, url).with(
|
85
80
|
headers: {
|
86
81
|
'Authorization' => "Token token=#{api_key}",
|
87
|
-
'Accept' => "application/json"
|
82
|
+
'Accept' => "application/json",
|
83
|
+
'User-Agent' => "onfido-ruby/#{Onfido::VERSION}"
|
88
84
|
}
|
89
85
|
)
|
90
86
|
end
|
@@ -113,7 +109,7 @@ describe Onfido::Resource do
|
|
113
109
|
end
|
114
110
|
|
115
111
|
it 'makes a request to an endpoint' do
|
116
|
-
expect(resource.public_send(method,
|
112
|
+
expect(resource.public_send(method, path: path, payload: payload)).
|
117
113
|
to eq(response)
|
118
114
|
end
|
119
115
|
end
|
@@ -127,7 +123,7 @@ describe Onfido::Resource do
|
|
127
123
|
end
|
128
124
|
|
129
125
|
it "raises a ConnectionError" do
|
130
|
-
expect { resource.public_send(method,
|
126
|
+
expect { resource.public_send(method, path: path, payload: payload) }.
|
131
127
|
to raise_error(Onfido::ConnectionError)
|
132
128
|
end
|
133
129
|
end
|