Sha256: 7ceaa3708603b4ab747bb700e9bf0292a70c0c24abf5d91a8ccaf0d36f604a18

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require_relative '../shared_contexts/with_document'

describe Onfido::Document do
  describe 'Documents' do
    include_context 'with document'

    it 'uploads a document' do
      expect(document).not_to be_nil
      expect(document.id).not_to be_empty
      expect(document.file_name).to eq('sample_driving_licence.png')
      expect(document).to be_an_instance_of(Onfido::Document)
    end

    it 'lists documents' do
      list_of_documents = onfido_api.list_documents(applicant_id)

      expect(list_of_documents).to be_an_instance_of(Onfido::DocumentsList)
      expect(list_of_documents.documents.size).to be > 0
    end

    it 'finds a document' do
      get_document = onfido_api.find_document(document_id)

      expect(get_document).to be_an_instance_of(Onfido::Document)
      expect(get_document.id).to eq document_id
    end

    it 'downloads a document' do
      file = onfido_api.download_document(document_id)

      expect(file.size).to be > 0
    end

    it 'cannot download an inexistent document' do
      inexistent_document_id = '00000000-0000-0000-0000-000000000000'
      
      expect {
        onfido_api.download_document(inexistent_document_id)
      }.to raise_error(Onfido::ApiError) { |e|
        expect(e.code).to eq(404)
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
onfido-3.4.0 spec/integrations/document_spec.rb
onfido-3.3.1 spec/integrations/document_spec.rb
onfido-3.3.0 spec/integrations/document_spec.rb
onfido-3.2.0 spec/integrations/document_spec.rb
onfido-3.1.0 spec/integrations/document_spec.rb
onfido-3.0.0 spec/integrations/document_spec.rb