Sha256: dd612f15e4b1823fb13affc78200c0db5ee43078c42e7e2d6974cd29c0f77dc8
Contents?: true
Size: 1.56 KB
Versions: 28
Compression:
Stored size: 1.56 KB
Contents
require 'spec_helper' fixture_path = 'spec/fixtures' describe 'numeric conversion of values' do it 'occurs by default' do options = {} data = SmarterCSV.process("#{fixture_path}/numeric.csv", options) data.size.should == 3 # all the keys should be symbols data.each do |hash| hash[:wealth].should be_a_kind_of(Numeric) unless hash[:wealth].nil? hash[:reference].should be_a_kind_of(Numeric) unless hash[:reference].nil? end end it 'can be prevented for all values' do options = { :convert_values_to_numeric => false } data = SmarterCSV.process("#{fixture_path}/numeric.csv", options) data.each do |hash| hash[:wealth].should be_a_kind_of(String) unless hash[:wealth].nil? hash[:reference].should be_a_kind_of(String) unless hash[:reference].nil? end end it 'can be prevented for some keys' do options = { :convert_values_to_numeric => { :except => :reference }} data = SmarterCSV.process("#{fixture_path}/numeric.csv", options) data.each do |hash| hash[:wealth].should be_a_kind_of(Numeric) unless hash[:wealth].nil? hash[:reference].should be_a_kind_of(String) unless hash[:reference].nil? end end it 'can occur only for some keys' do options = { :convert_values_to_numeric => { :only => :wealth }} data = SmarterCSV.process("#{fixture_path}/numeric.csv", options) data.each do |hash| hash[:wealth].should be_a_kind_of(Numeric) unless hash[:wealth].nil? hash[:reference].should be_a_kind_of(String) unless hash[:reference].nil? end end end
Version data entries
28 entries across 28 versions & 2 rubygems