# frozen_string_literal: true

require 'spec_helper'
require './boot'

describe ExtractExifData do
  let(:key) { 'raw/DSC04776.ARW' }
  let!(:photo) { Photo.create(id: key) }
  let(:file) { File.open('./spec/fixtures/DSC04776.ARW') }
  subject(:context) { ExtractExifData.call(params) }

  context 'with happy path' do
    let(:params) { { key: key, file: file, photo: photo } }

    describe '.call' do
      it 'succeeds' do
        expect(context).to be_a_success
      end

      it 'sets the exif data of the photo' do
        expect(context.exif_data).not_to be_blank
      end
    end
  end

  context 'without file' do
    let(:params) { { file: nil, key: key } }

    describe '.call' do
      it 'fails' do
        expect { context }.to raise_error(ArgumentError)
      end
    end
  end
end
