Permalink
Browse files

add spec for currency columns

  • Loading branch information...
1 parent b25bd21 commit e962acc2a8a110fbd4471b529765101422676379 @infused committed Mar 15, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 lib/dbf/column/base.rb
  2. +8 −0 spec/dbf/column_spec.rb
View
@@ -28,7 +28,7 @@ def type_cast(value)
when 'N' then unpack_number(value)
when 'I' then unpack_unsigned_long(value)
when 'F' then value.to_f
- when 'Y' then unpack_unsigned_long(value)/10000.0
+ when 'Y' then unpack_unsigned_long(value) / 10000.0
when 'D' then decode_date(value)
when 'T' then decode_datetime(value)
when 'L' then boolean(value)
View
@@ -137,6 +137,14 @@
end
end
+ context 'with type Y (currency)' do
+ let(:column) { DBF::Column::Dbase.new "ColumnName", "Y", 8, 4, "31" }
+
+ it 'casts to float' do
+ column.type_cast(" \xBF\x02\x00\x00\x00\x00\x00").should == 18.0
+ end
+ end
+
context "#schema_definition" do
context 'with type N (number)' do
it "outputs an integer column" do

0 comments on commit e962acc

Please sign in to comment.