spec/support/fake_onfido_api.rb in onfido-0.0.2 vs spec/support/fake_onfido_api.rb in onfido-0.0.3
- old
+ new
@@ -12,11 +12,12 @@
get '/v1/applicants/:id' do
json_response(200, 'applicant.json')
end
get '/v1/applicants' do
- json_response(200, 'applicants.json')
+ response = json_response(200, 'applicants.json')
+ {applicants: JSON.parse(response)['applicants'][pagination_range]}.to_json
end
post '/v1/applicants/:id/documents' do
json_response(201, 'document.json')
end
@@ -28,11 +29,12 @@
get '/v1/applicants/:id/checks/:id' do
json_response(200, 'check.json')
end
get '/v1/applicants/:id/checks' do
- json_response(200, 'checks.json')
+ response = json_response(200, 'checks.json')
+ {checks: JSON.parse(response)['checks'][pagination_range]}.to_json
end
get '/v1/checks/:id/reports' do
json_response(200, 'reports.json')
end
@@ -49,7 +51,13 @@
def json_response(response_code, file_name)
content_type :json
status response_code
File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read
+ end
+
+ def pagination_range
+ start = (params.fetch('page').to_i - 1) * 20
+ limit = start + params.fetch('per_page').to_i - 1
+ start..limit
end
end