Sha256: 7a0bd08c6658191fc40728cd01096b701e258c2480c319814a6ed79407a8face
Contents?: true
Size: 1.81 KB
Versions: 7
Compression:
Stored size: 1.81 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.each do |record| record.should be_an_instance_of(DBF::Record) end 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 + 0) @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 specify "column attributes should be accessible in underscored form" do @table.columns do |column| record = @table.records.first record.send(column_name).should == record.send(column_name.underscore) end end end
Version data entries
7 entries across 7 versions & 1 rubygems