rbankgiro 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/helper.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'test/unit'
2
+ require 'time'
3
+
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+
7
+ require 'rbankgiro'
8
+
9
+ def fixture_file_path(filename)
10
+ return '' if filename == ''
11
+ File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'helper'
2
+
3
+ class TestTransaction < Test::Unit::TestCase
4
+ def test_transaction
5
+ transactions = Rbankgiro::Transactions.new(fixture_file_path('one_transaction_09_02_27.txt'), '53090965')
6
+ transaction = transactions.first
7
+
8
+ assert_equal(false, transaction.rounding?)
9
+ assert_equal('86042103700000012', transaction.ocr)
10
+ assert_equal(1, transaction.amount)
11
+ assert_equal(Time.parse('Fri Feb 27 00:00:00 +0100 2009'), transaction.file_date)
12
+ end
13
+ end
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+
3
+ class TestTransactions < Test::Unit::TestCase
4
+ def test_one_transaction
5
+ transactions = Rbankgiro::Transactions.new(fixture_file_path('one_transaction_09_02_27.txt'), '53090965')
6
+
7
+ assert_equal(1, transactions.sum)
8
+ assert_equal(1, transactions.length)
9
+ assert_equal(Time.parse('Fri Feb 27 00:00:00 +0100 2009'), transactions.file_date)
10
+ end
11
+
12
+ def test_missing_transaction
13
+ assert_raise(Rbankgiro::PartSumError) do
14
+ Rbankgiro::Transactions.new(fixture_file_path('missing_transaction_09_02_27.txt'), '53090965')
15
+ end
16
+ end
17
+
18
+ def test_corrupt_header
19
+ assert_raise(Rbankgiro::CorruptHeader) do
20
+ Rbankgiro::Transactions.new(fixture_file_path('corrupt_header_09_02_27.txt'), '53090965')
21
+ end
22
+ end
23
+
24
+ def test_invalid_bankgiro_number
25
+ assert_raise(Rbankgiro::InvalidBankgiroNumber) do
26
+ Rbankgiro::Transactions.new(fixture_file_path('one_transaction_09_02_27.txt'), '53090966')
27
+ end
28
+ end
29
+
30
+ def test_file_format_error
31
+ assert_raise(Rbankgiro::FileFormatError) do
32
+ Rbankgiro::Transactions.new(fixture_file_path('file_format_error_09_02_27.txt'), '53090965')
33
+ end
34
+ end
35
+
36
+ # def test_transaction_count_error
37
+ # assert_raise(Rbankgiro::TransactionCountError) do
38
+ # Rbankgiro::Transactions.new(fixture_file_path('missing_transaction_09_02_27.txt'), '53090965')
39
+ # end
40
+ # end
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbankgiro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "Johan Eckerstr\xC3\xB6m"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-05 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Parsing transaction files from swedish Bankgiro central
17
+ email: johan@duh.se
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files: []
25
+
26
+ has_rdoc: true
27
+ homepage: http://github.com/jage/rbankgiro
28
+ licenses: []
29
+
30
+ post_install_message:
31
+ rdoc_options:
32
+ - --charset=UTF-8
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ version:
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ requirements: []
48
+
49
+ rubyforge_project:
50
+ rubygems_version: 1.3.5
51
+ signing_key:
52
+ specification_version: 3
53
+ summary: Parse Bankgiro transaction files
54
+ test_files:
55
+ - test/helper.rb
56
+ - test/test_transaction.rb
57
+ - test/test_transactions.rb