Sha256: d6c6cd810d28da4e50e87bb2ae0e88abebe69ee17e39b5d9fa7bb5d03b2d9c0d
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require 'spec_helper' fixture_path = 'spec/fixtures' describe 'test exceptions for invalid headers' do it 'does not raise an error if no required headers are given' do options = {:required_headers => nil} # order does not matter data = SmarterCSV.process("#{fixture_path}/user_import.csv", options) data.size.should eq 2 end it 'does not raise an error if no required headers are given' do options = {:required_headers => []} # order does not matter data = SmarterCSV.process("#{fixture_path}/user_import.csv", options) data.size.should eq 2 end it 'does not raise an error if the required headers are present' do options = {:required_headers => [:lastname,:email,:firstname,:manager_email]} # order does not matter data = SmarterCSV.process("#{fixture_path}/user_import.csv", options) data.size.should eq 2 end it 'raises an error if a required header is missing' do expect { options = {:required_headers => [:lastname,:email,:employee_id,:firstname,:manager_email]} # order does not matter SmarterCSV.process("#{fixture_path}/user_import.csv", options) }.to raise_exception(SmarterCSV::MissingHeaders) end it 'raises error on missing mapped headers and includes missing headers in message' do expect { # :age does not exist in the CSV header options = {:key_mapping => {:email => :a, :firstname => :b, :lastname => :c, :manager_email => :d, :age => :e} } SmarterCSV.process("#{fixture_path}/user_import.csv", options) }.to raise_exception(SmarterCSV::KeyMappingError, "missing header(s): age") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smarter_csv-1.6.0 | spec/smarter_csv/invalid_headers_spec.rb |
smarter_csv-1.5.2 | spec/smarter_csv/invalid_headers_spec.rb |