Sha256: f99841f98310b975fe0549efc8680df1d2920954173b4f7b614085013b4bcf4e
Contents?: true
Size: 1.2 KB
Versions: 3
Compression:
Stored size: 1.2 KB
Contents
require File.dirname(__FILE__) + "/../spec_helper" describe DBF::Record, "when initialized" do it "should typecast number columns with decimals == 0 to Integer" do table = DBF::Table.new "#{DB_PATH}/dbase_83.dbf" table.column("ID").type.should == "N" table.column("ID").decimal.should == 0 table.records.all? {|record| record.attributes['ID'].should be_kind_of(Integer)} end it "should typecast number columns with decimals > 0 to Float" do table = DBF::Table.new "#{DB_PATH}/dbase_83.dbf" table.column("ID").type.should == "N" table.column("COST").decimal.should == 2 table.records.all? {|record| record.attributes['COST'].should be_kind_of(Float)} end it "should typecast memo columns to String" do table = DBF::Table.new "#{DB_PATH}/dbase_83.dbf" table.column("DESC").type.should == "M" table.records.all? {|record| record.attributes['DESC'].should be_kind_of(String)} end it "should typecast logical columns to True or False" do table = DBF::Table.new "#{DB_PATH}/dbase_30.dbf" table.column("WEBINCLUDE").type.should == "L" table.records.all? {|record| record.attributes["WEBINCLUDE"].should satisfy {|v| v == true || v == false}} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dbf-1.0.0 | spec/unit/record_spec.rb |
dbf-1.0.1 | spec/unit/record_spec.rb |
dbf-1.0.2 | spec/unit/record_spec.rb |