Sha256: 770620b3716c5ca6e4bbc2b06b920f9547ed7d7bc457b10c53407dd5cfa6b2de

Contents?: true

Size: 920 Bytes

Versions: 4

Compression:

Stored size: 920 Bytes

Contents

require 'spec_helper'

fixture_path = 'spec/fixtures'

describe 'no header in file' do
  let(:headers) { [:a,:b,:c,:d,:e,:f] }
  let(:options) { {:headers_in_file => false, :user_provided_headers => headers} }
  subject(:data) { SmarterCSV.process("#{fixture_path}/no_header.csv", options) }

  it 'load the correct number of records' do
    data.size.should == 5
  end

  it 'uses given symbols for all records' do
    data.each do |item|
      item.keys.each do |key|
        [:a,:b,:c,:d,:e,:f].should include( key )
      end
    end
  end

  it 'loads the correct data' do
    data[0].should == {a: "Dan", b: "McAllister", c: 2, d: 0}
    data[1].should == {a: "Lucy", b: "Laweless", d: 5, e: 0}
    data[2].should == {a: "Miles", b: "O'Brian", c: 0, d: 0, e: 0, f: 21}
    data[3].should == {a: "Nancy", b: "Homes", c: 2, d: 0, e: 1}
    data[4].should == {a: "Hernán", b: "Curaçon", c: 3, d: 0, e: 0}
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smarter_csv-1.6.1 spec/smarter_csv/no_header_spec.rb
smarter_csv-1.6.0 spec/smarter_csv/no_header_spec.rb
smarter_csv-1.5.2 spec/smarter_csv/no_header_spec.rb
smarter_csv-1.5.1 spec/smarter_csv/no_header_spec.rb