ofx_br 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ofx/version.rb +1 -1
- data/spec/ofx/account_spec.rb +22 -22
- data/spec/ofx/ofx102_spec.rb +16 -16
- data/spec/ofx/ofx211_spec.rb +23 -24
- data/spec/ofx/ofx_parser_spec.rb +30 -31
- data/spec/ofx/ofx_spec.rb +5 -3
- data/spec/ofx/sign_on_spec.rb +4 -4
- data/spec/ofx/statement_spec.rb +28 -28
- data/spec/ofx/status_spec.rb +8 -8
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed6e8ceac8780584d6bde08b1e7f918886cc744f1002392bad7581d1ff0d044e
|
|
4
|
+
data.tar.gz: a15e6683152dcfd7fb6091364ce5441e32d182e7b1a30cb68e9c98ef6f177904
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6aeb038c88f9b48656704f4e51b348fb0a80c5c64956591032e9214b5c553eb8db3f5d815928a10aab47c80e6445dfca26c7382703c005095889a89ebf014233
|
|
7
|
+
data.tar.gz: 46a136b9f1c754425d379cf5c2e1ca9965af9bb5a3bbbb9f7a9212601ac1583ca60be5b3e26b824745ff34758b081565bef615f2094a9a6a2f922cae674838e8
|
data/lib/ofx/version.rb
CHANGED
data/spec/ofx/account_spec.rb
CHANGED
|
@@ -9,56 +9,56 @@ describe OFX::Account do
|
|
|
9
9
|
|
|
10
10
|
describe "account" do
|
|
11
11
|
it "should return currency" do
|
|
12
|
-
@account.currency.
|
|
12
|
+
expect(@account.currency).to eql "BRL"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should return bank id" do
|
|
16
|
-
@account.bank_id.
|
|
16
|
+
expect(@account.bank_id).to eql "0356"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should return id" do
|
|
20
|
-
@account.id.
|
|
20
|
+
expect(@account.id).to eql "03227113109"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "should return type" do
|
|
24
|
-
@account.type.
|
|
24
|
+
expect(@account.type).to eql :checking
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
it "should return transactions" do
|
|
28
|
-
@account.transactions.
|
|
29
|
-
@account.transactions.size.
|
|
28
|
+
expect(@account.transactions).to be_a_kind_of(Array)
|
|
29
|
+
expect(@account.transactions.size).to eql 36
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
it "should return balance" do
|
|
33
|
-
@account.balance.amount.
|
|
33
|
+
expect(@account.balance.amount).to eql BigDecimal('598.44')
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "should return balance in pennies" do
|
|
37
|
-
@account.balance.amount_in_pennies.
|
|
37
|
+
expect(@account.balance.amount_in_pennies).to eql 59844
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should return balance date" do
|
|
41
|
-
@account.balance.posted_at.
|
|
41
|
+
expect(@account.balance.posted_at).to eql Time.gm(2009,11,1)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
context "available_balance" do
|
|
45
45
|
it "should return available balance" do
|
|
46
|
-
@account.available_balance.amount.
|
|
46
|
+
expect(@account.available_balance.amount).to eql BigDecimal('1555.99')
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it "should return available balance in pennies" do
|
|
50
|
-
@account.available_balance.amount_in_pennies.
|
|
50
|
+
expect(@account.available_balance.amount_in_pennies).to eql 155599
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
it "should return available balance date" do
|
|
54
|
-
@account.available_balance.posted_at.
|
|
54
|
+
expect(@account.available_balance.posted_at).to eql Time.gm(2009,11,1)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should return nil if AVAILBAL not found" do
|
|
58
58
|
@ofx = OFX::Parser::Base.new("spec/fixtures/utf8.ofx")
|
|
59
59
|
@parser = @ofx.parser
|
|
60
60
|
@account = @parser.account
|
|
61
|
-
@account.available_balance.
|
|
61
|
+
expect(@account.available_balance).to be_nil
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -70,11 +70,11 @@ describe OFX::Account do
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "should return id" do
|
|
73
|
-
@account.id.
|
|
73
|
+
expect(@account.id).to eql "XXXXXXXXXXXX1111"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
it "should return currency" do
|
|
77
|
-
@account.currency.
|
|
77
|
+
expect(@account.currency).to eql "USD"
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
context "With Issue" do # Bradesco do not provide a valid date in balance
|
|
@@ -85,7 +85,7 @@ describe OFX::Account do
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
it "should return nil for date balance" do
|
|
88
|
-
@account.balance.posted_at.
|
|
88
|
+
expect(@account.balance.posted_at).to be_nil
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
|
|
@@ -98,8 +98,8 @@ describe OFX::Account do
|
|
|
98
98
|
expect { @parser.account.balance }.to_not raise_error
|
|
99
99
|
end
|
|
100
100
|
it "should return NIL in balance.posted_at when balance date is zero" do
|
|
101
|
-
@parser.account.balance.posted_at.
|
|
102
|
-
|
|
101
|
+
expect(@parser.account.balance.posted_at).to be_nil
|
|
102
|
+
end
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
context "decimal values using a comma" do
|
|
@@ -110,20 +110,20 @@ describe OFX::Account do
|
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
it "should return balance" do
|
|
113
|
-
@account.balance.amount.
|
|
113
|
+
expect(@account.balance.amount).to eql BigDecimal('348.29')
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
it "should return balance in pennies" do
|
|
117
|
-
@account.balance.amount_in_pennies.
|
|
117
|
+
expect(@account.balance.amount_in_pennies).to eql 34829
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
context "available_balance" do
|
|
121
121
|
it "should return available balance" do
|
|
122
|
-
@account.available_balance.amount.
|
|
122
|
+
expect(@account.available_balance.amount).to eql BigDecimal('2415.87')
|
|
123
123
|
end
|
|
124
124
|
|
|
125
125
|
it "should return available balance in pennies" do
|
|
126
|
-
@account.available_balance.amount_in_pennies.
|
|
126
|
+
expect(@account.available_balance.amount_in_pennies).to eql 241587
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
end
|
data/spec/ofx/ofx102_spec.rb
CHANGED
|
@@ -7,60 +7,60 @@ describe OFX::Parser::OFX102 do
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it "should have a version" do
|
|
10
|
-
OFX::Parser::OFX102::VERSION.
|
|
10
|
+
expect(OFX::Parser::OFX102::VERSION).to eql "1.0.2"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "should set headers" do
|
|
14
|
-
@parser.headers.
|
|
14
|
+
expect(@parser.headers).to eql @ofx.headers
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "should trim trailing whitespace from headers" do
|
|
18
18
|
headers = OFX::Parser::OFX102.parse_headers("VERSION:102 ")
|
|
19
|
-
headers["VERSION"].
|
|
19
|
+
expect(headers["VERSION"]).to eql "102"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "should set body" do
|
|
23
|
-
@parser.body.
|
|
23
|
+
expect(@parser.body).to eql @ofx.body
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should set account" do
|
|
27
|
-
@parser.account.
|
|
27
|
+
expect(@parser.account).to be_a_kind_of(OFX::Account)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should set account" do
|
|
31
|
-
@parser.sign_on.
|
|
31
|
+
expect(@parser.sign_on).to be_a_kind_of(OFX::SignOn)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
it "should set statements" do
|
|
35
|
-
@parser.statements.size.
|
|
36
|
-
@parser.statements.first.
|
|
35
|
+
expect(@parser.statements.size).to eql 1
|
|
36
|
+
expect(@parser.statements.first).to be_a_kind_of(OFX::Statement)
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
it "should know about all transaction types" do
|
|
40
40
|
valid_types = [
|
|
41
41
|
'CREDIT', 'DEBIT', 'INT', 'DIV', 'FEE', 'SRVCHG', 'DEP', 'ATM', 'POS', 'XFER',
|
|
42
42
|
'CHECK', 'PAYMENT', 'CASH', 'DIRECTDEP', 'DIRECTDEBIT', 'REPEATPMT', 'OTHER', 'IN', 'OUT'
|
|
43
43
|
]
|
|
44
|
-
valid_types.sort.
|
|
44
|
+
expect(valid_types.sort).to eql OFX::Parser::OFX102::TRANSACTION_TYPES.keys.sort
|
|
45
45
|
|
|
46
46
|
valid_types.each do |transaction_type|
|
|
47
|
-
transaction_type.downcase.to_sym.
|
|
47
|
+
expect(transaction_type.downcase.to_sym).to equal(OFX::Parser::OFX102::TRANSACTION_TYPES[transaction_type])
|
|
48
48
|
end
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
describe "#build_date" do
|
|
52
52
|
context "without a Time Zone" do
|
|
53
53
|
it "should default to GMT" do
|
|
54
|
-
@parser.send(:build_date, "20170904").
|
|
55
|
-
@parser.send(:build_date, "20170904082855").
|
|
54
|
+
expect(@parser.send(:build_date, "20170904")).to eql Time.gm(2017, 9, 4)
|
|
55
|
+
expect(@parser.send(:build_date, "20170904082855")).to eql Time.gm(2017, 9, 4, 8, 28, 55)
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
context "with a Time Zone" do
|
|
60
60
|
it "should returns the correct date" do
|
|
61
|
-
@parser.send(:build_date, "20150507164333[-0300:BRT]").
|
|
62
|
-
@parser.send(:build_date, "20180507120000[0:GMT]").
|
|
63
|
-
@parser.send(:build_date, "20170904082855[-3:GMT]").
|
|
61
|
+
expect(@parser.send(:build_date, "20150507164333[-0300:BRT]")).to eql Time.new(2015, 5, 7, 16, 43, 33, "-03:00")
|
|
62
|
+
expect(@parser.send(:build_date, "20180507120000[0:GMT]")).to eql Time.gm(2018, 5, 7, 12)
|
|
63
|
+
expect(@parser.send(:build_date, "20170904082855[-3:GMT]")).to eql Time.new(2017, 9, 4, 8, 28, 55, "-03:00")
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|
data/spec/ofx/ofx211_spec.rb
CHANGED
|
@@ -7,32 +7,32 @@ describe OFX::Parser::OFX211 do
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
it "should have a version" do
|
|
10
|
-
OFX::Parser::OFX211::VERSION.
|
|
10
|
+
expect(OFX::Parser::OFX211::VERSION).to eql "2.1.1"
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it "should set headers" do
|
|
14
|
-
@parser.headers.
|
|
14
|
+
expect(@parser.headers).to eql @ofx.headers
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it "should set body" do
|
|
18
|
-
@parser.body.
|
|
18
|
+
expect(@parser.body).to eql @ofx.body
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
it "should set account" do
|
|
22
|
-
@parser.account.
|
|
22
|
+
expect(@parser.account).to be_a_kind_of(OFX::Account)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
it "should set account" do
|
|
26
|
-
@parser.sign_on.
|
|
26
|
+
expect(@parser.sign_on).to be_a_kind_of(OFX::SignOn)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "should set accounts" do
|
|
30
|
-
@parser.accounts.size.
|
|
30
|
+
expect(@parser.accounts.size).to eql 2
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
it "should set statements" do
|
|
34
|
-
@parser.statements.size.
|
|
35
|
-
@parser.statements.first.
|
|
34
|
+
expect(@parser.statements.size).to eql 2
|
|
35
|
+
expect(@parser.statements.first).to be_a_kind_of(OFX::Statement)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
context "transactions" do
|
|
@@ -44,11 +44,11 @@ describe OFX::Parser::OFX211 do
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
it "should contain the correct values" do
|
|
47
|
-
@t.amount.
|
|
48
|
-
@t.fit_id.
|
|
49
|
-
@t.memo.
|
|
50
|
-
@t.posted_at.
|
|
51
|
-
@t.name.
|
|
47
|
+
expect(@t.amount).to eql BigDecimal('-80')
|
|
48
|
+
expect(@t.fit_id).to eql "219378"
|
|
49
|
+
expect(@t.memo).to be_empty
|
|
50
|
+
expect(@t.posted_at).to eql Time.parse("2005-08-24 08:00:00 +0000")
|
|
51
|
+
expect(@t.name).to eql "FrogKick Scuba Gear"
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -58,11 +58,11 @@ describe OFX::Parser::OFX211 do
|
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "should contain the correct values" do
|
|
61
|
-
@t.amount.
|
|
62
|
-
@t.fit_id.
|
|
63
|
-
@t.memo.
|
|
64
|
-
@t.posted_at.
|
|
65
|
-
@t.name.
|
|
61
|
+
expect(@t.amount).to eql BigDecimal('-23')
|
|
62
|
+
expect(@t.fit_id).to eql "219867"
|
|
63
|
+
expect(@t.memo).to be_empty
|
|
64
|
+
expect(@t.posted_at).to eql Time.parse("2005-08-11 08:00:00 +0000")
|
|
65
|
+
expect(@t.name).to eql "Interest Charge"
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
|
|
@@ -72,13 +72,12 @@ describe OFX::Parser::OFX211 do
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "should contain the correct values" do
|
|
75
|
-
@t.amount.
|
|
76
|
-
@t.fit_id.
|
|
77
|
-
@t.memo.
|
|
78
|
-
@t.posted_at.
|
|
79
|
-
@t.name.
|
|
75
|
+
expect(@t.amount).to eql BigDecimal('350')
|
|
76
|
+
expect(@t.fit_id).to eql "219868"
|
|
77
|
+
expect(@t.memo).to be_empty
|
|
78
|
+
expect(@t.posted_at).to eql Time.parse("2005-08-11 08:00:00 +0000")
|
|
79
|
+
expect(@t.name).to eql "Payment - Thank You"
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
|
-
|
data/spec/ofx/ofx_parser_spec.rb
CHANGED
|
@@ -18,44 +18,44 @@ describe OFX::Parser do
|
|
|
18
18
|
|
|
19
19
|
it "should accept file path" do
|
|
20
20
|
@ofx = OFX::Parser::Base.new("spec/fixtures/sample.ofx")
|
|
21
|
-
@ofx.content.
|
|
21
|
+
expect(@ofx.content).not_to be_nil
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
it "should accept file handler" do
|
|
25
25
|
file = open("spec/fixtures/sample.ofx")
|
|
26
26
|
@ofx = OFX::Parser::Base.new(file)
|
|
27
|
-
@ofx.content.
|
|
27
|
+
expect(@ofx.content).not_to be_nil
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it "should accept file content" do
|
|
31
31
|
file = open("spec/fixtures/sample.ofx").read
|
|
32
32
|
@ofx = OFX::Parser::Base.new(file)
|
|
33
|
-
@ofx.content.
|
|
33
|
+
expect(@ofx.content).not_to be_nil
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "should set content" do
|
|
37
|
-
@ofx.content.
|
|
37
|
+
expect(@ofx.content).to eql open("spec/fixtures/sample.ofx").read
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "should work with UTF8 and Latin1 encodings" do
|
|
41
41
|
@ofx = OFX::Parser::Base.new("spec/fixtures/utf8.ofx")
|
|
42
|
-
@ofx.content.
|
|
42
|
+
expect(@ofx.content).to eql open("spec/fixtures/utf8.ofx").read
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it "should set body" do
|
|
46
|
-
@ofx.body.
|
|
46
|
+
expect(@ofx.body).not_to be_nil
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
it "should raise exception when trying to parse an unsupported OFX version" do
|
|
50
|
-
|
|
50
|
+
expect {
|
|
51
51
|
OFX::Parser::Base.new("spec/fixtures/invalid_version.ofx")
|
|
52
|
-
}.
|
|
52
|
+
}.to raise_error(OFX::UnsupportedFileError)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "should raise exception when trying to parse an invalid file" do
|
|
56
|
-
|
|
56
|
+
expect {
|
|
57
57
|
OFX::Parser::Base.new("spec/fixtures/avatar.gif")
|
|
58
|
-
}.
|
|
58
|
+
}.to raise_error(OFX::UnsupportedFileError)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "should use 102 parser to parse version 100 ofx files" do
|
|
@@ -80,22 +80,21 @@ describe OFX::Parser do
|
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it "should use 211 parser to parse version 200 ofx files" do
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
allow(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
|
|
85
84
|
ofx = OFX::Parser::Base.new(ofx_example_to('200'))
|
|
86
|
-
ofx.parser.
|
|
85
|
+
expect(ofx.parser).to eql 'ofx-211-parser'
|
|
87
86
|
end
|
|
88
87
|
|
|
89
88
|
it "should use 211 parser to parse version 202 ofx files" do
|
|
90
|
-
OFX::Parser::OFX211.
|
|
89
|
+
allow(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
|
|
91
90
|
ofx = OFX::Parser::Base.new(ofx_example_to('202'))
|
|
92
|
-
ofx.parser.
|
|
91
|
+
expect(ofx.parser).to eql 'ofx-211-parser'
|
|
93
92
|
end
|
|
94
93
|
|
|
95
94
|
it "should use 211 parser to parse version 211 ofx files" do
|
|
96
|
-
OFX::Parser::OFX211.
|
|
95
|
+
allow(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
|
|
97
96
|
ofx = OFX::Parser::Base.new(ofx_example_to('211'))
|
|
98
|
-
ofx.parser.
|
|
97
|
+
expect(ofx.parser).to eql 'ofx-211-parser'
|
|
99
98
|
end
|
|
100
99
|
|
|
101
100
|
it "should use 211 parser to parse version 220 ofx files" do
|
|
@@ -107,43 +106,43 @@ describe OFX::Parser do
|
|
|
107
106
|
|
|
108
107
|
describe "headers" do
|
|
109
108
|
it "should have OFXHEADER" do
|
|
110
|
-
@ofx.headers["OFXHEADER"].
|
|
109
|
+
expect(@ofx.headers["OFXHEADER"]).to eql "100"
|
|
111
110
|
end
|
|
112
111
|
|
|
113
112
|
it "should have DATA" do
|
|
114
|
-
@ofx.headers["DATA"].
|
|
113
|
+
expect(@ofx.headers["DATA"]).to eql "OFXSGML"
|
|
115
114
|
end
|
|
116
115
|
|
|
117
116
|
it "should have VERSION" do
|
|
118
|
-
@ofx.headers["VERSION"].
|
|
117
|
+
expect(@ofx.headers["VERSION"]).to eql "102"
|
|
119
118
|
end
|
|
120
119
|
|
|
121
120
|
it "should have SECURITY" do
|
|
122
|
-
@ofx.headers.
|
|
123
|
-
@ofx.headers["SECURITY"].
|
|
121
|
+
expect(@ofx.headers).to have_key("SECURITY")
|
|
122
|
+
expect(@ofx.headers["SECURITY"]).to be_nil
|
|
124
123
|
end
|
|
125
124
|
|
|
126
125
|
it "should have ENCODING" do
|
|
127
|
-
@ofx.headers["ENCODING"].
|
|
126
|
+
expect(@ofx.headers["ENCODING"]).to eql "USASCII"
|
|
128
127
|
end
|
|
129
128
|
|
|
130
129
|
it "should have CHARSET" do
|
|
131
|
-
@ofx.headers["CHARSET"].
|
|
130
|
+
expect(@ofx.headers["CHARSET"]).to eql "1252"
|
|
132
131
|
end
|
|
133
132
|
|
|
134
133
|
it "should have COMPRESSION" do
|
|
135
|
-
@ofx.headers.
|
|
136
|
-
@ofx.headers["COMPRESSION"].
|
|
134
|
+
expect(@ofx.headers).to have_key("COMPRESSION")
|
|
135
|
+
expect(@ofx.headers["COMPRESSION"]).to be_nil
|
|
137
136
|
end
|
|
138
137
|
|
|
139
138
|
it "should have OLDFILEUID" do
|
|
140
|
-
@ofx.headers.
|
|
141
|
-
@ofx.headers["OLDFILEUID"].
|
|
139
|
+
expect(@ofx.headers).to have_key("OLDFILEUID")
|
|
140
|
+
expect(@ofx.headers["OLDFILEUID"]).to be_nil
|
|
142
141
|
end
|
|
143
142
|
|
|
144
143
|
it "should have NEWFILEUID" do
|
|
145
|
-
@ofx.headers.
|
|
146
|
-
@ofx.headers["NEWFILEUID"].
|
|
144
|
+
expect(@ofx.headers).to have_key("NEWFILEUID")
|
|
145
|
+
expect(@ofx.headers["NEWFILEUID"]).to be_nil
|
|
147
146
|
end
|
|
148
147
|
|
|
149
148
|
it "should parse headers with CR and without LF" do
|
|
@@ -152,7 +151,7 @@ describe OFX::Parser do
|
|
|
152
151
|
ofx_with_carriage_return = header + "<OFX>" + body
|
|
153
152
|
|
|
154
153
|
@ofx = OFX::Parser::Base.new(ofx_with_carriage_return)
|
|
155
|
-
@ofx.headers.size.
|
|
154
|
+
expect(@ofx.headers.size).to be(9)
|
|
156
155
|
end
|
|
157
156
|
end
|
|
158
157
|
end
|
data/spec/ofx/ofx_spec.rb
CHANGED
|
@@ -4,18 +4,20 @@ describe OFX do
|
|
|
4
4
|
describe "#OFX" do
|
|
5
5
|
it "should yield an OFX instance" do
|
|
6
6
|
OFX("spec/fixtures/sample.ofx") do |ofx|
|
|
7
|
-
ofx.class.
|
|
7
|
+
expect(ofx.class).to eql OFX::Parser::OFX102
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it "should be an OFX instance" do
|
|
12
|
+
klass = nil
|
|
12
13
|
OFX("spec/fixtures/sample.ofx") do
|
|
13
|
-
self.class
|
|
14
|
+
klass = self.class
|
|
14
15
|
end
|
|
16
|
+
expect(klass).to eql OFX::Parser::OFX102
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
it "should return parser" do
|
|
18
|
-
OFX("spec/fixtures/sample.ofx").class.
|
|
20
|
+
expect(OFX("spec/fixtures/sample.ofx").class).to eql OFX::Parser::OFX102
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
data/spec/ofx/sign_on_spec.rb
CHANGED
|
@@ -9,19 +9,19 @@ describe OFX::SignOn do
|
|
|
9
9
|
|
|
10
10
|
describe "sign_on" do
|
|
11
11
|
it "should return language" do
|
|
12
|
-
@sign_on.language.
|
|
12
|
+
expect(@sign_on.language).to eql "ENG"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should return Financial Institution ID" do
|
|
16
|
-
@sign_on.fi_id.
|
|
16
|
+
expect(@sign_on.fi_id).to eql "24909"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should return Financial Institution Name" do
|
|
20
|
-
@sign_on.fi_name.
|
|
20
|
+
expect(@sign_on.fi_name).to eql "Citigroup"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "should return status" do
|
|
24
|
-
@sign_on.status.
|
|
24
|
+
expect(@sign_on.status).to be_a(OFX::Status)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
end
|
data/spec/ofx/statement_spec.rb
CHANGED
|
@@ -8,41 +8,41 @@ describe OFX::Statement do
|
|
|
8
8
|
let(:ofx) { OFX::Parser::Base.new("spec/fixtures/sample.ofx") }
|
|
9
9
|
|
|
10
10
|
it "returns currency" do
|
|
11
|
-
statement.currency.
|
|
11
|
+
expect(statement.currency).to eql "BRL"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it "returns start date" do
|
|
15
|
-
statement.start_date.
|
|
15
|
+
expect(statement.start_date).to eql Time.parse("2009-10-09 08:00:00 +0000")
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "returns end date" do
|
|
19
|
-
statement.end_date.
|
|
19
|
+
expect(statement.end_date).to eql Time.parse("2009-11-03 08:00:00 +0000")
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "returns account" do
|
|
23
|
-
statement.account.
|
|
24
|
-
statement.account.id.
|
|
25
|
-
statement.account.type.
|
|
23
|
+
expect(statement.account).to be_a(OFX::Account)
|
|
24
|
+
expect(statement.account.id).to eql '03227113109'
|
|
25
|
+
expect(statement.account.type).to eql :checking
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it "returns transactions" do
|
|
29
|
-
statement.transactions.
|
|
30
|
-
statement.transactions.size.
|
|
29
|
+
expect(statement.transactions).to be_a(Array)
|
|
30
|
+
expect(statement.transactions.size).to eql 36
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
describe "balance" do
|
|
34
34
|
let(:balance) { statement.balance }
|
|
35
35
|
|
|
36
36
|
it "returns balance" do
|
|
37
|
-
balance.amount.
|
|
37
|
+
expect(balance.amount).to eql BigDecimal('598.44')
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
it "returns balance in pennies" do
|
|
41
|
-
balance.amount_in_pennies.
|
|
41
|
+
expect(balance.amount_in_pennies).to eql 59844
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
it "returns balance date" do
|
|
45
|
-
balance.posted_at.
|
|
45
|
+
expect(balance.posted_at).to eql Time.parse("2009-11-01 00:00:00 +0000")
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -50,22 +50,22 @@ describe OFX::Statement do
|
|
|
50
50
|
let(:available_balance) { statement.available_balance }
|
|
51
51
|
|
|
52
52
|
it "returns available balance" do
|
|
53
|
-
available_balance.amount.
|
|
53
|
+
expect(available_balance.amount).to eql BigDecimal('1555.99')
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
it "returns available balance in pennies" do
|
|
57
|
-
available_balance.amount_in_pennies.
|
|
57
|
+
expect(available_balance.amount_in_pennies).to eql 155599
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
it "returns available balance date" do
|
|
61
|
-
available_balance.posted_at.
|
|
61
|
+
expect(available_balance.posted_at).to eql Time.parse("2009-11-01 00:00:00 +0000")
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
context "when AVAILBAL not found" do
|
|
65
65
|
let(:ofx) { OFX::Parser::Base.new("spec/fixtures/utf8.ofx") }
|
|
66
66
|
|
|
67
67
|
it "returns nil " do
|
|
68
|
-
available_balance.
|
|
68
|
+
expect(available_balance).to be_nil
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
end
|
|
@@ -75,40 +75,40 @@ describe OFX::Statement do
|
|
|
75
75
|
let(:ofx) { OFX::Parser::Base.new("spec/fixtures/creditcard.ofx") }
|
|
76
76
|
|
|
77
77
|
it "returns currency" do
|
|
78
|
-
statement.currency.
|
|
78
|
+
expect(statement.currency).to eql "USD"
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "returns start date" do
|
|
82
|
-
statement.start_date.
|
|
82
|
+
expect(statement.start_date).to eql Time.parse("2007-05-09 12:00:00 +0000")
|
|
83
83
|
end
|
|
84
84
|
|
|
85
85
|
it "returns end date" do
|
|
86
|
-
statement.end_date.
|
|
86
|
+
expect(statement.end_date).to eql Time.parse("2007-06-08 12:00:00 +0000")
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "returns account" do
|
|
90
|
-
statement.account.
|
|
91
|
-
statement.account.id.
|
|
90
|
+
expect(statement.account).to be_a(OFX::Account)
|
|
91
|
+
expect(statement.account.id).to eql 'XXXXXXXXXXXX1111'
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
it "returns transactions" do
|
|
95
|
-
statement.transactions.
|
|
96
|
-
statement.transactions.size.
|
|
95
|
+
expect(statement.transactions).to be_a(Array)
|
|
96
|
+
expect(statement.transactions.size).to eql 3
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
describe "balance" do
|
|
100
100
|
let(:balance) { statement.balance }
|
|
101
101
|
|
|
102
102
|
it "returns balance" do
|
|
103
|
-
balance.amount.
|
|
103
|
+
expect(balance.amount).to eql BigDecimal('-1111.01')
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it "returns balance in pennies" do
|
|
107
|
-
balance.amount_in_pennies.
|
|
107
|
+
expect(balance.amount_in_pennies).to eql -111101
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
it "returns balance date" do
|
|
111
|
-
balance.posted_at.
|
|
111
|
+
expect(balance.posted_at).to eql Time.parse("2007-06-23 19:20:13 +0000")
|
|
112
112
|
end
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -116,15 +116,15 @@ describe OFX::Statement do
|
|
|
116
116
|
let(:available_balance) { statement.available_balance }
|
|
117
117
|
|
|
118
118
|
it "returns available balance" do
|
|
119
|
-
available_balance.amount.
|
|
119
|
+
expect(available_balance.amount).to eql BigDecimal('19000.99')
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
it "returns available balance in pennies" do
|
|
123
|
-
available_balance.amount_in_pennies.
|
|
123
|
+
expect(available_balance.amount_in_pennies).to eql 1900099
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
it "returns available balance date" do
|
|
127
|
-
available_balance.posted_at.
|
|
127
|
+
expect(available_balance.posted_at).to eql Time.parse("2007-06-23 19:20:13 +0000")
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
end
|
data/spec/ofx/status_spec.rb
CHANGED
|
@@ -9,19 +9,19 @@ describe OFX::Status do
|
|
|
9
9
|
let(:ofx_file) { "spec/fixtures/creditcard.ofx" }
|
|
10
10
|
|
|
11
11
|
it "should return code" do
|
|
12
|
-
status.code.
|
|
12
|
+
expect(status.code).to eql 0
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it "should return severity" do
|
|
16
|
-
status.severity.
|
|
16
|
+
expect(status.severity).to eql :info
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it "should return message" do
|
|
20
|
-
status.message.
|
|
20
|
+
expect(status.message).to eql ""
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it "should be successful" do
|
|
24
|
-
status.success
|
|
24
|
+
expect(status.success?).to eql true
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
@@ -29,19 +29,19 @@ describe OFX::Status do
|
|
|
29
29
|
let(:ofx_file) { "spec/fixtures/error.ofx" }
|
|
30
30
|
|
|
31
31
|
it "should return code" do
|
|
32
|
-
status.code.
|
|
32
|
+
expect(status.code).to eql 2000
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "should return severity" do
|
|
36
|
-
status.severity.
|
|
36
|
+
expect(status.severity).to eql :error
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it "should return message" do
|
|
40
|
-
status.message.
|
|
40
|
+
expect(status.message).to eql "We were unable to process your request. Please try again later."
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "should not be successful" do
|
|
44
|
-
status.success
|
|
44
|
+
expect(status.success?).to eql false
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ofx_br
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nando Vieira
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-04-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: nokogiri
|
|
@@ -20,7 +20,7 @@ dependencies:
|
|
|
20
20
|
version: 1.13.1
|
|
21
21
|
- - "<"
|
|
22
22
|
- !ruby/object:Gem::Version
|
|
23
|
-
version: 1.
|
|
23
|
+
version: 1.19.2
|
|
24
24
|
type: :runtime
|
|
25
25
|
prerelease: false
|
|
26
26
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -30,7 +30,7 @@ dependencies:
|
|
|
30
30
|
version: 1.13.1
|
|
31
31
|
- - "<"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.
|
|
33
|
+
version: 1.19.2
|
|
34
34
|
- !ruby/object:Gem::Dependency
|
|
35
35
|
name: byebug
|
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|