test/mt940_triodos_test.rb in mt940-0.6.6 vs test/mt940_triodos_test.rb in mt940-0.7.0
- old
+ new
@@ -1,45 +1,122 @@
require 'helper'
class TestMt940Triodos < Test::Unit::TestCase
- def setup
- file_name = File.dirname(__FILE__) + '/fixtures/triodos.txt'
- @transactions = MT940::Base.transactions(file_name)
- @transaction = @transactions.first
- end
-
- should 'have the correct number of transactions' do
- assert_equal 2, @transactions.size
- end
+ context 'Before sepa' do
- context 'Transaction' do
- should 'have a bank_account' do
- assert_equal '390123456', @transaction.bank_account
+ setup do
+ file_name = File.dirname(__FILE__) + '/fixtures/triodos.txt'
+ @transactions = MT940::Parser.new(file_name).transactions
end
-
- should 'have an amount' do
- assert_equal -15.7, @transaction.amount
+
+ should 'have the correct number of transactions' do
+ assert_equal 2, @transactions.size
end
- should 'have a currency' do
- assert_equal 'EUR', @transaction.currency
- end
+ context 'Transaction' do
- should 'have a description' do
- assert_equal 'ALGEMENE TUSSENREKENING KOSTEN VAN 01-10-2010 TOT EN M ET 31-12-20100390123456', @transaction.description
- end
+ setup do
+ @transaction = @transactions.first
+ end
- should 'have a date' do
- assert_equal Date.new(2011,1,1), @transaction.date
+ should 'have a bank_account' do
+ assert_equal '390123456', @transaction.bank_account
+ end
+
+ should 'have an amount' do
+ assert_equal -15.7, @transaction.amount
+ end
+
+ should 'have a currency' do
+ assert_equal 'EUR', @transaction.currency
+ end
+
+ should 'have a description' do
+ assert_equal 'ALGEMENE TUSSENREKENING KOSTEN VAN 01-10-2010 TOT EN MET 31-12-2010', @transaction.description
+ end
+
+ should 'have a date' do
+ assert_equal Date.new(2011,1,1), @transaction.date
+ end
+
+ should 'return its bank' do
+ assert_equal 'Triodos', @transaction.bank
+ end
+
+ should 'return the contra_account' do
+ assert_equal '987654321', @transaction.contra_account
+ end
+
end
- should 'return its bank' do
- assert_equal 'Triodos', @transaction.bank
+ end
+
+ context 'After sepa' do
+
+ setup do
+ file_name = File.dirname(__FILE__) + '/fixtures/triodos_sepa.txt'
+ @transactions = MT940::Parser.new(file_name).transactions
end
+
+ should 'have the correct number of transactions' do
+ assert_equal 8, @transactions.size
+ end
- should 'return the contra_account' do
- assert_equal '987654321', @transaction.contra_account
+ context 'Transaction' do
+
+ setup do
+ @transaction = @transactions.first
+ end
+
+ should 'have a bank_account' do
+ assert_equal '666666666', @transaction.bank_account
+ end
+
+ should 'have an amount' do
+ assert_equal -10.00, @transaction.amount
+ end
+
+ should 'have a currency' do
+ assert_equal 'EUR', @transaction.currency
+ end
+
+ context 'description' do
+
+ setup do
+ @description = 'TENAAMSTELLING TEGENREKENING EN ADRES TEGENREKENING EN PLAATS TEGENREKENING EN EEN LANGE OMSCHRIJVING VAN DE TRANSACTIE'
+ end
+
+ should 'have the description in case of BBAN' do
+ assert_equal @description, @transaction.description
+ end
+
+ should 'have the description in case of IBAN' do
+ assert_equal @description, @transactions[2].description
+ end
+
+ end
+
+ should 'have a date' do
+ assert_equal Date.new(2012,11,23), @transaction.date
+ end
+
+ should 'return its bank' do
+ assert_equal 'Triodos', @transaction.bank
+ end
+
+ context 'contra_account' do
+
+ should 'return the contra_account in case of a BBAN' do
+ assert_equal '555555555', @transaction.contra_account
+ end
+
+ should 'return the contra_account in case of a IBAN' do
+ assert_equal 'AA99BBBB0555555555', @transactions[2].contra_account
+ end
+
+ end
+
end
end
end