spec/support/fake_onfido_api.rb in onfido-2.8.0 vs spec/support/fake_onfido_api.rb in onfido-2.9.0

- old
+ new

@@ -9,11 +9,11 @@ end class FakeOnfidoAPI < Sinatra::Base # rubocop:disable Metrics/ClassLength before do begin - if request.content_type == "application/json; charset=utf-8" + if request.content_type == 'application/json; charset=utf-8' body_parameters = JSON.parse(request.body.read) params.merge!(body_parameters) if body_parameters end rescue JSON::ParserError end @@ -247,10 +247,14 @@ get '/v3.6/workflow_runs/:id' do json_response(200, 'workflow_run.json') end + get '/v3.6/workflow_runs/:id/signed_evidence_file' do + pdf_response(200, 'signed_workflow_run.pdf') + end + get '/v3.6/workflow_runs' do json_response(200, 'workflow_runs.json') end get '/v3.6/4xx_response' do @@ -268,12 +272,20 @@ end private def json_response(response_code, file_name) - content_type 'application/json; charset=utf-8' + fixture_response(response_code, file_name, 'application/json') + end + + def fixture_response(response_code, file_name, custom_content_type) + content_type "#{custom_content_type}; charset=utf-8" status response_code - File.open("#{File.dirname(__FILE__)}/fixtures/#{file_name}", 'rb').read + File.binread("#{File.dirname(__FILE__)}/fixtures/#{file_name}") + end + + def pdf_response(response_code, file_name) + fixture_response(response_code, file_name, 'application/pdf') end def pagination_range start = (params.fetch('page').to_i - 1) * 20 limit = start + params.fetch('per_page').to_i - 1