Sha256: 2039b2dca328286e653edda75b80540911d21795e79fe35d4669b2329bbf4bf5
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe CSVHash do before(:all) do @csv_path = File.expand_path(File.join(File.dirname(__FILE__),'assets','test.csv')) @clean_csv_path = File.expand_path(File.join(File.dirname(__FILE__),'assets','clean_test.csv')) end describe "from_file" do before(:all) do @array, @columns = CSVHash.from_file(@csv_path) end it "should get correct column names (no spaces)" do @columns.should == "one,two,foo__bar__three,foo__bar__four,foo__five,bar__six,bar__seven".split(',') end it "should only include data rows" do @array.should have(2).rows_of_hashes end it "should parse properly" do first = { "one" => "1", "two" => "2", "foo" => { "bar" => {"three" => "3", "four" => "4"}, "five" => "5" }, "bar" => {"six" => "6", "seven" => "7"} } @array.first.should == first second = { "one" => "14", "two" => "13", "foo" => { "bar" => {"three" => "12", "four" => "11"}, "five" => "10" }, "bar" => {"six" => "9", "seven" => "8"} } @array.last.should == second end end it "should do a round trip" do CSVHash.to_string(*CSVHash.from_file(@csv_path)).chomp.should == File.open(@clean_csv_path).read.chomp end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
csv-hash-0.1.1 | spec/csv-hash_spec.rb |
csv-hash-0.1.0 | spec/csv-hash_spec.rb |