Sha256: 59a9af344efcb41a3974b46291d081970c65ae79c1ee79081071738dd9b6b24f

Contents?: true

Size: 845 Bytes

Versions: 5

Compression:

Stored size: 845 Bytes

Contents

require 'spec_helper'

fixture_path = 'spec/fixtures'

describe 'can handle the difficult CSV file' do

  it 'loads the data with default values' do
    data = SmarterCSV.process("#{fixture_path}/hard_sample.csv")
    data.size.should eq 1
    item = data.first
    item.keys.count.should == 48
    item[:name].should == '#MR1220817'
    item[:shipping_method].should == 'Livraison Standard GRATUITE, 2-5 jours avec suivi'
    item[:lineitem_name].should == 'Cire Épilation Nacrée'
    item[:phone].should == 3366012111111
  end

  # the main problem is the data line starting with a # character, but not being a comment
  it 'fails to load the CSV file with incorrectly set comment_regexp' do
    options = {comment_regexp: /\A#/ }
    data = SmarterCSV.process("#{fixture_path}/hard_sample.csv", options)
    data.size.should eq 0
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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