Sha256: f68c6b0006c0ce2c437fc7c8b87d863b01a53d5f9a32e2ea4fa4278abe4a474c

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

include Fathom

describe CSVImport do
  
  before do
    @content =<<-END
      this,and,that
      1,2,3
      4,5,6
      7,8,9
    END
    
    @opts = {:content => @content}
    @ci = CSVImport.new(@opts)
    @result = @ci.import
  end
  
  it "should not work unless content is set" do
    lambda{CSVImport.new.import}.should raise_error(NoMethodError)
    lambda{CSVImport.new(@opts)}.should_not raise_error
  end
  
  it "should create as many data nodes as there are columns" do
    @result.size.should eql(3)
    @result.each {|dn| dn.should be_a(DataNode)}
  end
  
  it "should import the values from each column into each data node" do
    @result[0].values.should eql([1,4,7])
    @result[1].values.should eql([2,5,8])
    @result[2].values.should eql([3,6,9])
  end
  
  it "should store the imported values in the knowledge base" do
    Fathom.knowledge_base[:this].should be_a(DataNode)
    Fathom.kb[:this].values.should eql([1,4,7])
  end

  it "should import from the class level" do
    CSVImport.import(@opts)
    Fathom.knowledge_base[:this].should be_a(DataNode)
    Fathom.kb[:this].values.should eql([1,4,7])
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fathom-0.2.3 spec/fathom/import/csv_import_spec.rb
fathom-0.2.2 spec/fathom/import/csv_import_spec.rb
fathom-0.2.1 spec/fathom/import/csv_import_spec.rb
fathom-0.2.0 spec/fathom/import/csv_import_spec.rb