spec/reckon/app_spec.rb in reckon-0.3.3 vs spec/reckon/app_spec.rb in reckon-0.3.4
- old
+ new
@@ -11,10 +11,11 @@
@chase = Reckon::App.new(:string => CHASE_CSV)
@some_other_bank = Reckon::App.new(:string => SOME_OTHER_CSV)
@two_money_columns = Reckon::App.new(:string => TWO_MONEY_COLUMNS_BANK)
@simple_csv = Reckon::App.new(:string => SIMPLE_CSV)
@german_date = Reckon::App.new(:string => GERMAN_DATE_EXAMPLE)
+ @danish_kroner_nordea = Reckon::App.new(:string => DANISH_KRONER_NORDEA_EXAMPLE, :csv_separator => ';', :comma_separates_cents => true)
end
it "should be in testing mode" do
@chase.settings[:testing].should be_true
Reckon::App.settings[:testing].should be_true
@@ -45,24 +46,27 @@
it "should detect the money column" do
@chase.money_column_indices.should == [3]
@some_other_bank.money_column_indices.should == [3]
@two_money_columns.money_column_indices.should == [3, 4]
@harder_date_example_csv.money_column_indices.should == [1]
+ @danish_kroner_nordea.money_column_indices.should == [3]
end
it "should detect the date column" do
@chase.date_column_index.should == 1
@some_other_bank.date_column_index.should == 1
@two_money_columns.date_column_index.should == 0
@harder_date_example_csv.date_column_index.should == 0
+ @danish_kroner_nordea.date_column_index.should == 0
end
it "should consider all other columns to be description columns" do
@chase.description_column_indices.should == [0, 2]
@some_other_bank.description_column_indices.should == [0, 2]
@two_money_columns.description_column_indices.should == [1, 2, 5]
@harder_date_example_csv.description_column_indices.should == [2, 3, 4, 5, 6, 7]
+ @danish_kroner_nordea.description_column_indices.should == [1, 2, 4]
end
end
describe "each_index_backwards" do
it "should hit every index" do
@@ -83,10 +87,16 @@
@two_money_columns.money_for(0).should == -76
@two_money_columns.money_for(1).should == 327.49
@two_money_columns.money_for(2).should == -800
@two_money_columns.money_for(3).should == -88.55
@two_money_columns.money_for(4).should == 88.55
+ @danish_kroner_nordea.money_for(0).should == -48.00
+ @danish_kroner_nordea.money_for(1).should == -79.00
+ @danish_kroner_nordea.money_for(2).should == 497.90
+ @danish_kroner_nordea.money_for(3).should == -995.00
+ @danish_kroner_nordea.money_for(4).should == -3452.90
+ @danish_kroner_nordea.money_for(5).should == -655.00
end
it "should handle the comma_separates_cents option correctly" do
european_csv = Reckon::App.new(:string => "$2,00;something\n1.025,67;something else", :csv_separator => ';', :comma_separates_cents => true)
european_csv.money_for(0).should == 2.00
@@ -103,10 +113,13 @@
@some_other_bank.date_for(1).month.should == Time.parse("2010/12/24").month
@some_other_bank.date_for(1).day.should == Time.parse("2010/12/24").day
@german_date.date_for(1).year.should == Time.parse("2009/12/24").year
@german_date.date_for(1).month.should == Time.parse("2009/12/24").month
@german_date.date_for(1).day.should == Time.parse("2009/12/24").day
+ @danish_kroner_nordea.date_for(0).year.should == Time.parse("2012/11/16").year
+ @danish_kroner_nordea.date_for(0).month.should == Time.parse("2012/11/16").month
+ @danish_kroner_nordea.date_for(0).day.should == Time.parse("2012/11/16").day
end
end
describe "description_for" do
it "should return the combined fields that are not money for date fields" do
@@ -182,6 +195,16 @@
GERMAN_DATE_EXAMPLE = (<<-CSV).strip
24.12.2009,Check - 0000000122,122,-$76.00,"","$1,750.06"
24.12.2009,BLARG R SH 456930,"","",+$327.49,"$1,826.06"
24.12.2009,Check - 0000000112,112,-$800.00,"","$1,498.57"
CSV
+
+ DANISH_KRONER_NORDEA_EXAMPLE = (<<-CSV).strip
+ 16-11-2012;Dankort-nota DSB Kobenhavn 15149;16-11-2012;-48,00;26550,33
+ 26-10-2012;Dankort-nota Ziggy Cafe 19471;26-10-2012;-79,00;26054,54
+ 22-10-2012;Dankort-nota H&M Hennes & M 10681;23-10-2012;497,90;25433,54
+ 12-10-2012;Visa kob DKK 995,00 WWW.ASOS.COM 00000 ;12-10-2012;-995,00;27939,54
+ 12-09-2012;Dankort-nota B.J. TRADING E 14660;12-09-2012;-3452,90;26164,80
+ 27-08-2012;Dankort-nota MATAS - 20319 18230;27-08-2012;-655,00;21127,45
+ CSV
+
end