Sha256: 23f4b793a42e2354d158ee9db6c2d2c5af04513384d6fc8bd2c27045fc82ba98

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

describe DBF, :shared => true do
  specify "sum of column lengths should equal record length specified in header" do
    header_record_length = @table.instance_eval {@record_length}
    sum_of_column_lengths = @table.columns.inject(1) {|sum, column| sum + column.length}
    
    header_record_length.should == sum_of_column_lengths
  end

  specify "records should be instances of DBF::Record" do
    @table.records.all? {|record| record.should be_an_instance_of(DBF::Record)}
  end
  
  specify "columns should be instances of DBF::Column" do
    @table.columns.all? {|column| column.should be_an_instance_of(DBF::Column)}
  end
  
  specify "column names should not be blank" do
    @table.columns.all? {|column| column.name.should_not be_empty}
  end
  
  specify "column types should be valid" do
    valid_column_types = %w(C N L D M F B G P Y T I V X @ O +)
    @table.columns.all? {|column| valid_column_types.should include(column.type)}
  end
  
  specify "column lengths should be instances of Fixnum" do
    @table.columns.all? {|column| column.length.should be_an_instance_of(Fixnum)}
  end
  
  specify "column lengths should be larger than 0" do
    @table.columns.all? {|column| column.length.should > 0}
  end
  
  specify "column decimals should be instances of Fixnum" do
    @table.columns.all? {|column| column.decimal.should be_an_instance_of(Fixnum)}
  end
  
  specify "column read accessors should return the attribute after typecast" do
    @table.columns do |column|
      record = table.records.first
      record.send(column.name).should == record[column.name]
    end
  end
  
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
infused-dbf-1.0.7 spec/functional/dbf_shared.rb
infused-dbf-1.0.8 spec/functional/dbf_shared.rb
infused-dbf-1.0.9 spec/functional/dbf_shared.rb
dbf-1.0.10 spec/functional/dbf_shared.rb
dbf-1.0.9 spec/functional/dbf_shared.rb
dbf-1.0.8 spec/functional/dbf_shared.rb
dbf-1.0.6 spec/functional/dbf_shared.rb
dbf-1.0.7 spec/functional/dbf_shared.rb