diff --git a/spec/integrations/report_spec.rb b/spec/integrations/report_spec.rb index 2c2054d..95f5dfb 100644 --- a/spec/integrations/report_spec.rb +++ b/spec/integrations/report_spec.rb @@ -23,13 +23,15 @@ def sort_reports(reports_list) end it 'finds a report' do - get_document_report = onfido_api.find_report(document_report_id) + get_document_report = repeat_request_until_status_changes(Onfido::ReportStatus::COMPLETE) { + onfido_api.find_report(document_report_id) + } get_identity_report = onfido_api.find_report(identity_report_id) expect(get_document_report).to be_an_instance_of Onfido::DocumentReport expect(get_document_report.id).to eq document_report_id expect(get_document_report.name).to eq Onfido::ReportName::DOCUMENT - expect(get_document_report.status).to eq Onfido::ReportStatus::AWAITING_DATA + expect(get_document_report.status).to eq Onfido::ReportStatus::COMPLETE expect(get_identity_report).to be_an_instance_of Onfido::IdentityEnhancedReport expect(get_identity_report.id).to eq identity_report_id diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 68badda..e7c28b6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -65,7 +65,7 @@ Kernel.srand config.seed end -def repeat_request_until_status_changes(expected_status, max_retries = 10, +def repeat_request_until_status_changes(expected_status, max_retries = 15, interval = 1, &proc) # expected_status --> desired status # max_retries --> how many times to retry the request @@ -86,7 +86,7 @@ def repeat_request_until_status_changes(expected_status, max_retries = 10, instance end -def repeat_request_until_task_output_changes(max_retries = 10, +def repeat_request_until_task_output_changes(max_retries = 15, interval = 1, &proc) # max_retries --> how many times to retry the request # interval --> how many seconds to wait until the next retry @@ -106,7 +106,7 @@ def repeat_request_until_task_output_changes(max_retries = 10, instance end -def repeat_request_unti_http_code_changes(max_retries = 10, +def repeat_request_unti_http_code_changes(max_retries = 15, interval = 1, &proc) # max_retries --> how many times to retry the request # interval --> how many seconds to wait until the next retry