Sha256: b3cccda7826048f3e109f8d0edd719422cf7a9ab15c16d2b8cf8ca254da6b59c

Contents?: true

Size: 866 Bytes

Versions: 12

Compression:

Stored size: 866 Bytes

Contents

require 'spec_helper'

fixture_path = 'spec/fixtures'

describe 'be_able_to' do
  it 'ignore comments in CSV files' do
    options = {}
    data = SmarterCSV.process("#{fixture_path}/ignore_comments.csv", options)

    data.size.should eq 5

    # all the keys should be symbols
    data.each{|item| item.keys.each{|x| x.is_a?(Symbol).should be_truthy}}
    data.each do |h|
      h.keys.each do |key|
        [:"not_a_comment#first_name", :last_name, :dogs, :cats, :birds, :fish].should include( key )
      end
    end
  end

  it 'ignore comments in CSV files with CRLF' do
    options = {row_sep: "\r\n"}
    data = SmarterCSV.process("#{fixture_path}/ignore_comments2.csv", options)

    # all the keys should be symbols
    data.size.should eq 1
    data.first[:h1].should eq 'a'
    data.first[:h2].should eq "b\r\n#c"
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
smarter_csv-1.4.2 spec/smarter_csv/ignore_comments_spec.rb
smarter_csv-1.4.0 spec/smarter_csv/ignore_comments_spec.rb
smarter_csv-1.3.0 spec/smarter_csv/ignore_comments_spec.rb
smarter_csv-1.2.8 spec/smarter_csv/ignore_comments_spec.rb
smarter_csv-1.2.7 spec/smarter_csv/ignore_comments_spec.rb
pokedex-terminal-0.2.8 vendor/bundle/ruby/2.7.0/gems/smarter_csv-1.2.6/spec/smarter_csv/ignore_comments_spec.rb
pokedex-terminal-0.2.7 vendor/bundle/ruby/2.7.0/gems/smarter_csv-1.2.6/spec/smarter_csv/ignore_comments_spec.rb
pokedex-terminal-0.2.6 vendor/bundle/ruby/2.7.0/gems/smarter_csv-1.2.6/spec/smarter_csv/ignore_comments_spec.rb
pokedex-terminal-0.2.5 vendor/bundle/ruby/2.7.0/gems/smarter_csv-1.2.6/spec/smarter_csv/ignore_comments_spec.rb
pokedex-terminal-0.2.4 vendor/bundle/ruby/2.7.0/gems/smarter_csv-1.2.6/spec/smarter_csv/ignore_comments_spec.rb
smarter_csv-1.2.6 spec/smarter_csv/ignore_comments_spec.rb
smarter_csv-1.2.5 spec/smarter_csv/ignore_comments_spec.rb