spec/integrations/live_photo_spec.rb in onfido-0.8.4 vs spec/integrations/live_photo_spec.rb in onfido-0.9.0

- old
+ new

@@ -2,21 +2,31 @@ describe Onfido::LivePhoto do subject(:live_photo) { described_class.new } describe '#create' do - after do - file.close - file.unlink + let(:params) { { file: file } } + + context 'with a File-like object to upload' do + let(:file) { Tempfile.new(['passport', '.jpg']) } + + after do + file.close + file.unlink + end + + it 'creates a new photo' do + response = live_photo.create('foobar', params) + expect(response['id']).not_to be_nil + end end - let(:file) { Tempfile.new(['photo', '.jpg']) } - before { allow(live_photo).to receive(:open).and_return(:file) } - let(:params) { { file: file } } - let(:applicant_id) { '1030303-123123-123123' } + context 'passing in a non-File-like file to upload' do + let(:file) { 'https://onfido.com/images/photo.jpg' } - it 'creates a new photo' do - response = live_photo.create('foobar', params) - expect(response['id']).not_to be_nil + it 'raises an ArgumentError' do + expect { live_photo.create('foobar', params) }. + to raise_error(ArgumentError, /must be a `File`-like object/) + end end end end