Sha256: 4ac2723562de5fdc42daa53419de2cf2e53c03504a4ddec84662b83f0748bf51
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require File.join(File.dirname(__FILE__),'../../spec_helper') describe IMW::Formats::Csv do # we don't test Tsv as the differences from Csv are trivial and # effect only code within the FasterCSV library before do @sample = IMW.open(File.join(IMWTest::DATA_DIR, 'formats/delimited/sample.csv')) end it "should be able to parse the CSV" do @sample.load[1].last.should == 'lemurinus' end it "should be able to write CSV" do data = [['foobar', 1, 2], ['bazbooz', 3, 4]] IMW.open!('test.csv') { |f| f << data } IMW.open('test.csv').load[1].last.should == "4" end describe "guessing a schema" do Dir[File.join(IMWTest::DATA_DIR, 'formats/delimited/with_schema/*')].each do |path| it "should correctly guess that with_schema/#{File.basename(path)} has headers in its first row" do IMW.open(path).fields_in_first_line?.should == true end end Dir[File.join(IMWTest::DATA_DIR, 'formats/delimited/without_schema/*')].each do |path| it "should correctly guess that without_schema/#{File.basename(path)} does not have headers in its first row" do IMW.open(path).fields_in_first_line?.should == false end end it "should automatically set the headers on a source with guessed headers" do resource = IMW.open(Dir[File.join(IMWTest::DATA_DIR, 'formats/delimited/with_schema/*')].first) resource.guess_fields! resource.delimited_options[:headers].class.should == Array resource.schema.should_not be_empty end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
imw-0.2.18 | spec/imw/formats/delimited_spec.rb |
imw-0.2.17 | spec/imw/formats/delimited_spec.rb |