Sha256: 93cf438cdb54857a1872d38b33570725bf35d2703c0d64516c124ae0921c83e4

Contents?: true

Size: 836 Bytes

Versions: 2

Compression:

Stored size: 836 Bytes

Contents

require File.dirname(__FILE__) + "/../spec_helper"

describe DBF::Field, "when initialized" do
  
  before(:each) do
    @field = DBF::Field.new "FieldName", "N", 1, 0
  end
  
  it "should set the #name accessor" do
    @field.name.should == "FieldName"
  end
  
  it "should set the #type accessor" do
    @field.type.should == "N"
  end
  
  it "should set the #length accessor" do
    @field.length.should == 1
  end
  
  it "should set the #decimal accessor" do
    @field.decimal.should == 0
  end
  
  it "should raise an error if length is greater than 0" do
    lambda { field = DBF::Field.new "FieldName", "N", -1, 0 }.should raise_error(DBF::FieldLengthError)
  end
  
  it "should strip null characters from the name" do
    field = DBF::Field.new "Field\0Name\0", "N", 1, 0
    field.name.should == "FieldName"
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dbf-0.5.3 spec/unit/field_spec.rb
dbf-0.5.4 spec/unit/field_spec.rb