Sha256: 50b2224ec2643498db9d90d3b69f950da82629f0d9b28c2b9b2bea4b2880dbbc

Contents?: true

Size: 1022 Bytes

Versions: 2

Compression:

Stored size: 1022 Bytes

Contents

require 'spec_helper'

describe Roo::CSV do
  let(:path) { 'test/files/csvtypes.csv' }
  let(:csv) { Roo::CSV.new(path) }

  describe '.new' do
    it 'creates an instance' do
      expect(csv).to be_a(Roo::CSV)
    end
  end

  describe '#parse' do
    subject do
      csv.parse(options)
    end
    context 'with headers: true' do
      let(:options) { { headers: true } }

      it "doesn't blow up" do
        expect { subject }.to_not raise_error
      end
    end
  end

  describe '#csv_options' do
    context 'when created with the csv_options option' do
      let(:options) do
        {
          col_sep: '\t',
          quote_char: "'"
        }
      end

      it 'returns the csv options' do
        csv = Roo::CSV.new(path, csv_options: options)
        expect(csv.csv_options).to eq(options)
      end
    end

    context 'when created without the csv_options option' do
      it 'returns a hash' do
        csv = Roo::CSV.new(path)
        expect(csv.csv_options).to eq({})
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
culturecode-roo-2.0.1 spec/lib/roo/csv_spec.rb
roo-andyw8-2.0.0 spec/lib/roo/csv_spec.rb