test/mt940_ing_test.rb in mt940-0.6.6 vs test/mt940_ing_test.rb in mt940-0.7.0

- old
+ new

@@ -1,46 +1,100 @@ require 'helper' class TestMt940Ing < Test::Unit::TestCase - def setup - file_name = File.dirname(__FILE__) + '/fixtures/ing.txt' - @transactions = MT940::Base.transactions(file_name) - @transaction = @transactions.first - end - - should 'have the correct number of transactions' do - assert_equal 6, @transactions.size - end - - context 'Transaction' do - should 'have a bank_account' do - assert_equal '001234567', @transaction.bank_account + context 'Before SEPA' do + setup do + file_name = File.dirname(__FILE__) + '/fixtures/ing.txt' + @transactions = MT940::Parser.new(file_name).transactions end - - should 'have an amount' do - assert_equal -25.03, @transaction.amount + + should 'have the correct number of transactions' do + assert_equal 6, @transactions.size end - should 'have a currency' do - assert_equal 'EUR', @transaction.currency - end + context 'Transaction' do - should 'have a date' do - assert_equal Date.new(2010,7,22), @transaction.date - end + setup do + @transaction = @transactions.first + end - should 'return its bank' do - assert_equal 'Ing', @transaction.bank - end + should 'have a bank_account' do + assert_equal '001234567', @transaction.bank_account + end - should 'have a description' do - assert_equal 'EJ46GREENP100610T1456 CLIEOP TMG GPHONGKONG AMSTERDAM', @transactions.last.description + should 'have an amount' do + assert_equal -25.03, @transaction.amount + end + + should 'have a currency' do + assert_equal 'EUR', @transaction.currency + end + + should 'have a date' do + assert_equal Date.new(2010,7,22), @transaction.date + end + + should 'return its bank' do + assert_equal 'Ing', @transaction.bank + end + + should 'have a description' do + assert_equal 'EJ46GREENP100610T1456 CLIEOP TMG GPHONGKONG AMSTERDAM', @transactions.last.description + end + + should 'return the contra_account' do + assert_equal '123456789', @transactions.last.contra_account + end + end + end - should 'return the contra_account' do - assert_equal '123456789', @transactions.last.contra_account + context 'After SEPA' do + setup do + # Fixture contains a mixture of transactions with and without iban numbers + file_name = File.dirname(__FILE__) + '/fixtures/ing_sepa.txt' + @transactions = MT940::Parser.new(file_name).transactions end + + should 'have the correct number of transactions' do + assert_equal 8, @transactions.size + end + context 'Transaction' do + + setup do + @transaction = @transactions.first + end + + should 'have a bank_account' do + assert_equal '654321789', @transaction.bank_account + end + + should 'have an amount' do + assert_equal 1.41, @transaction.amount + end + + should 'have a currency' do + assert_equal 'EUR', @transaction.currency + end + + should 'have a date' do + assert_equal Date.new(2012,8,10), @transaction.date + end + + should 'return its bank' do + assert_equal 'Ing', @transaction.bank + end + + should 'have a description' do + assert_equal 'J. Janssen 20120123456789 Factuurnr 123456 Klantnr 00123', @transactions[1].description + end + + should 'return the contra_account' do + assert_equal 'NL69INGB0123456789', @transactions[1].contra_account + end + + end end end