Sha256: ccab2030d22519677557741f8522ff04a3c15a97115eff08e9af20136600f797

Contents?: true

Size: 775 Bytes

Versions: 20

Compression:

Stored size: 775 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe 'importing a csv batch', :clean do
  subject(:importer) { Zizia::Importer.new(parser: parser) }
  let(:parser)       { Zizia::CsvParser.new(file: file) }
  let(:file)         { File.open('spec/fixtures/example.csv') }

  it 'creates a record for each CSV line' do
    expect { importer.import }.to change { Work.count }.to 3
  end

  describe 'validation' do
    context 'with invalid CSV' do
      let(:file) { File.open('spec/fixtures/bad_example.csv') }

      it 'outputs invalid file notice to Rails.logger' do
        expect(Rails.logger).to receive(:error).with("[zizia] CSV::MalformedCSVError: Illegal quoting in line 2. (Zizia::CsvFormatValidator)")
        parser.validate
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
zizia-6.0.1 spec/dummy/spec/integration/import_csv_spec.rb
zizia-6.0.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.5.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.4.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.3.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.2.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.1.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.0.1 spec/dummy/spec/integration/import_csv_spec.rb
zizia-5.0.0 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.6.0.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.5.4.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.5.3.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.5.2.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.5.1.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.4.1.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.4.0.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.3.1.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.2.0.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.1.0.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb
zizia-4.0.4.alpha.01 spec/dummy/spec/integration/import_csv_spec.rb