ofx_br 0.3.3 → 0.3.9

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +2 -2
  3. data/lib/{ofx_br → ofx}/parser/ofx102.rb +13 -8
  4. data/lib/{ofx_br → ofx}/parser.rb +1 -3
  5. data/lib/ofx/statement.rb +11 -0
  6. data/lib/{ofx_br → ofx}/version.rb +1 -1
  7. data/lib/ofx.rb +34 -0
  8. data/spec/{ofx_br → ofx}/ofx102_spec.rb +1 -1
  9. data/spec/{ofx_br → ofx}/ofx_parser_spec.rb +53 -18
  10. data/spec/{ofx_br → ofx}/transaction_spec.rb +53 -34
  11. data/spec/spec_helper.rb +8 -3
  12. metadata +109 -86
  13. data/.github/dependabot.yml +0 -13
  14. data/.gitignore +0 -4
  15. data/.rspec +0 -1
  16. data/.travis.yml +0 -9
  17. data/Gemfile +0 -2
  18. data/Gemfile.lock +0 -50
  19. data/lib/ofx_br/parser/ofx103.rb +0 -7
  20. data/lib/ofx_br/statement.rb +0 -5
  21. data/lib/ofx_br.rb +0 -33
  22. data/ofx_br.gemspec +0 -32
  23. data/spec/fixtures/avatar.gif +0 -0
  24. data/spec/fixtures/bb.ofx +0 -700
  25. data/spec/fixtures/bradesco.ofx +0 -96
  26. data/spec/fixtures/creditcard.ofx +0 -79
  27. data/spec/fixtures/dtsof_balance_issue.ofx +0 -54
  28. data/spec/fixtures/error.ofx +0 -24
  29. data/spec/fixtures/invalid_version.ofx +0 -308
  30. data/spec/fixtures/nd-amex-sample.ofx +0 -12
  31. data/spec/fixtures/sample.ofx +0 -315
  32. data/spec/fixtures/santander.ofx +0 -91
  33. data/spec/fixtures/utf8.ofx +0 -308
  34. data/spec/fixtures/v103.ofx +0 -80
  35. data/spec/fixtures/v211.ofx +0 -85
  36. data/spec/ofx_br/ofx103_spec.rb +0 -50
  37. /data/lib/{ofx_br → ofx}/account.rb +0 -0
  38. /data/lib/{ofx_br → ofx}/balance.rb +0 -0
  39. /data/lib/{ofx_br → ofx}/errors.rb +0 -0
  40. /data/lib/{ofx_br → ofx}/foundation.rb +0 -0
  41. /data/lib/{ofx_br → ofx}/parser/ofx211.rb +0 -0
  42. /data/lib/{ofx_br → ofx}/sign_on.rb +0 -0
  43. /data/lib/{ofx_br → ofx}/status.rb +0 -0
  44. /data/lib/{ofx_br → ofx}/transaction.rb +0 -0
  45. /data/spec/{ofx_br → ofx}/account_spec.rb +0 -0
  46. /data/spec/{ofx_br → ofx}/ofx211_spec.rb +0 -0
  47. /data/spec/{ofx_br → ofx}/ofx_spec.rb +0 -0
  48. /data/spec/{ofx_br → ofx}/sign_on_spec.rb +0 -0
  49. /data/spec/{ofx_br → ofx}/statement_spec.rb +0 -0
  50. /data/spec/{ofx_br → ofx}/status_spec.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7762b34050e1cb1c3cd7191d88bdbff23902c771a4e76e50ec960ead46464bb7
4
- data.tar.gz: 4fb5f842f6592c125a07007dc7e33aefb7ec6b72a37c0c9d270f374d3f16e424
3
+ metadata.gz: 309a2f8c617d20621c0b74246b98f11c2d0238d1276e20a621a5394cc535fc03
4
+ data.tar.gz: fc1aaf2c9cab36a00bb2a214313ca77d87e3a60d509075acf7a73780440cce04
5
5
  SHA512:
6
- metadata.gz: ec56cc287b9b1c4accc141a97ffbb7f10c649cb4a29ee4b5234ef77aee52d413ee65177b26d20d33a5c468610bf2a4734aff9cedcaee881efc12bbfb3dab800e
7
- data.tar.gz: ebc5b4d3243f90de88678b0cd696e47fd9c01e160ad529946936b1276ca55f9d892e60b0b11122ab3a7e972dabe9c8234fba0c0b5641509defcc9aecf7d3ba73
6
+ metadata.gz: 53d5f474a247925251de8e0e8a5a1a52774394d0176441117d735cf1810fe48526f81f57890080ae0c9f3bfd513961c0251df2dfb99f9a74b1135ca7a2d21d61
7
+ data.tar.gz: 9771c21506ca49e9d534fb5fcd13b4d8712f3964b3b3c92f27e2e492c43af490f255285ad86bd2c9f813d50b3eafe754a73367113fa8bf573d34921b0079def4
data/README.rdoc CHANGED
@@ -1,7 +1,7 @@
1
1
  = OFX
2
2
 
3
- {<img src="https://badge.fury.io/rb/ofx.png" alt="Gem Version" />}[http://badge.fury.io/rb/ofx]
4
- {<img src="https://travis-ci.org/annacruz/ofx.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/annacruz/ofx]
3
+ {<img src="https://badge.fury.io/rb/ofx.svg" alt="Gem Version" />}[https://badge.fury.io/rb/ofx]
4
+ {<img src="https://github.com/annacruz/ofx/actions/workflows/config.yml/badge.svg" alt="Build Status" />}[https://github.com/annacruz/ofx/actions]
5
5
 
6
6
  A simple OFX (Open Financial Exchange) parser built on top of Nokogiri. Currently supports both OFX 1.0.2 and 2.1.1.
7
7
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OFX
2
4
  module Parser
3
5
  class OFX102
@@ -8,28 +10,27 @@ module OFX
8
10
  'SAVINGS' => :savings,
9
11
  'CREDITLINE' => :creditline,
10
12
  'MONEYMRKT' => :moneymrkt
11
- }
13
+ }.freeze
12
14
 
13
15
  TRANSACTION_TYPES = %w[
14
16
  ATM CASH CHECK CREDIT DEBIT DEP DIRECTDEBIT DIRECTDEP DIV
15
- FEE INT OTHER PAYMENT POS REPEATPMT SRVCHG XFER
16
- ].each_with_object({}) { |tran_type, hash| hash[tran_type] = tran_type.downcase.to_sym; }
17
+ FEE INT OTHER PAYMENT POS REPEATPMT SRVCHG XFER IN OUT
18
+ ].each_with_object({}) do |tran_type, hash|
19
+ hash[tran_type] = tran_type.downcase.to_sym
20
+ end
17
21
 
18
22
  SEVERITY = {
19
23
  'INFO' => :info,
20
24
  'WARN' => :warn,
21
25
  'ERROR' => :error
22
- }
26
+ }.freeze
23
27
 
24
- attr_reader :headers, :body, :html, :date_start, :date_end
28
+ attr_reader :headers, :body, :html
25
29
 
26
30
  def initialize(options = {})
27
31
  @headers = options[:headers]
28
32
  @body = options[:body]
29
33
  @html = Nokogiri::HTML.parse(body)
30
-
31
- @date_start ||= build_date(@html.search('banktranlist > dtstart').inner_text)
32
- @date_end ||= build_date(@html.search('banktranlist > dtend').inner_text)
33
34
  end
34
35
 
35
36
  def statements
@@ -72,6 +73,8 @@ module OFX
72
73
  account = build_account(node)
73
74
  OFX::Statement.new(
74
75
  currency: stmrs_node.search('curdef').inner_text,
76
+ start_date: build_date(stmrs_node.search('banktranlist > dtstart').inner_text),
77
+ end_date: build_date(stmrs_node.search('banktranlist > dtend').inner_text),
75
78
  account: account,
76
79
  transactions: account.transactions,
77
80
  balance: account.balance,
@@ -195,6 +198,8 @@ module OFX
195
198
 
196
199
  def to_decimal(amount)
197
200
  BigDecimal(amount.to_s.gsub(',', '.'))
201
+ rescue ArgumentError
202
+ BigDecimal('0.0')
198
203
  end
199
204
  end
200
205
  end
@@ -17,10 +17,8 @@ module OFX
17
17
  end
18
18
 
19
19
  case headers["VERSION"]
20
- when /102/ then
20
+ when /100|102|103/ then
21
21
  @parser = OFX102.new(:headers => headers, :body => body)
22
- when /103/ then
23
- @parser = OFX103.new(:headers => headers, :body => body)
24
22
  when /200|202|211|220/ then
25
23
  @parser = OFX211.new(:headers => headers, :body => body)
26
24
  else
@@ -0,0 +1,11 @@
1
+ module OFX
2
+ class Statement < Foundation
3
+ attr_accessor :account
4
+ attr_accessor :available_balance
5
+ attr_accessor :balance
6
+ attr_accessor :currency
7
+ attr_accessor :start_date
8
+ attr_accessor :end_date
9
+ attr_accessor :transactions
10
+ end
11
+ end
@@ -2,7 +2,7 @@ module OFX
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- PATCH = 3
5
+ PATCH = 9
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/lib/ofx.rb ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open-uri'
4
+ require 'nokogiri'
5
+ require 'bigdecimal'
6
+
7
+ require 'kconv'
8
+
9
+ require 'ofx/errors'
10
+ require 'ofx/parser'
11
+ require 'ofx/parser/ofx102'
12
+ require 'ofx/parser/ofx211'
13
+ require 'ofx/foundation'
14
+ require 'ofx/balance'
15
+ require 'ofx/account'
16
+ require 'ofx/sign_on'
17
+ require 'ofx/status'
18
+ require 'ofx/statement'
19
+ require 'ofx/transaction'
20
+ require 'ofx/version'
21
+
22
+ def OFX(resource, &block)
23
+ parser = OFX::Parser::Base.new(resource).parser
24
+
25
+ if block_given?
26
+ if block.arity == 1
27
+ yield parser
28
+ else
29
+ parser.instance_eval(&block)
30
+ end
31
+ end
32
+
33
+ parser
34
+ end
@@ -39,7 +39,7 @@ describe OFX::Parser::OFX102 do
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
- 'CHECK', 'PAYMENT', 'CASH', 'DIRECTDEP', 'DIRECTDEBIT', 'REPEATPMT', 'OTHER'
42
+ 'CHECK', 'PAYMENT', 'CASH', 'DIRECTDEP', 'DIRECTDEBIT', 'REPEATPMT', 'OTHER', 'IN', 'OUT'
43
43
  ]
44
44
  valid_types.sort.should == OFX::Parser::OFX102::TRANSACTION_TYPES.keys.sort
45
45
 
@@ -1,6 +1,17 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe OFX::Parser do
4
+ def ofx_example_to(version)
5
+ <<~OFX_CONTENT
6
+ <?xml version="1.0" encoding="US-ASCII"?>
7
+
8
+ <?OFX OFXHEADER="200" VERSION="#{version}" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>"
9
+
10
+ <OFX>
11
+ </OFX>
12
+ OFX_CONTENT
13
+ end
14
+
4
15
  before do
5
16
  @ofx = OFX::Parser::Base.new("spec/fixtures/sample.ofx")
6
17
  end
@@ -47,18 +58,53 @@ describe OFX::Parser do
47
58
  }.should raise_error(OFX::UnsupportedFileError)
48
59
  end
49
60
 
61
+ it "should use 102 parser to parse version 100 ofx files" do
62
+ expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser')
63
+
64
+ ofx = OFX::Parser::Base.new(ofx_example_to('100'))
65
+ expect(ofx.parser).to eql 'ofx-102-parser'
66
+ end
67
+
68
+ it "should use 102 parser to parse version 102 ofx files" do
69
+ expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser')
70
+
71
+ ofx = OFX::Parser::Base.new(ofx_example_to('102'))
72
+ expect(ofx.parser).to eql 'ofx-102-parser'
73
+ end
74
+
75
+ it "should use 102 parser to parse version 103 ofx files" do
76
+ expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser')
77
+
78
+ ofx = OFX::Parser::Base.new(ofx_example_to('103'))
79
+ expect(ofx.parser).to eql 'ofx-102-parser'
80
+ end
81
+
50
82
  it "should use 211 parser to parse version 200 ofx files" do
51
- OFX::Parser::OFX211.stub(:new).and_return('ofx-211-parser')
52
- ofx = OFX::Parser::Base.new(ofx_2_example('200'))
83
+ expect(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
84
+
85
+ ofx = OFX::Parser::Base.new(ofx_example_to('200'))
53
86
  ofx.parser.should == 'ofx-211-parser'
54
87
  end
55
88
 
56
89
  it "should use 211 parser to parse version 202 ofx files" do
57
90
  OFX::Parser::OFX211.stub(:new).and_return('ofx-211-parser')
58
- ofx = OFX::Parser::Base.new(ofx_2_example('202'))
91
+ ofx = OFX::Parser::Base.new(ofx_example_to('202'))
59
92
  ofx.parser.should == 'ofx-211-parser'
60
93
  end
61
94
 
95
+ it "should use 211 parser to parse version 211 ofx files" do
96
+ OFX::Parser::OFX211.stub(:new).and_return('ofx-211-parser')
97
+ ofx = OFX::Parser::Base.new(ofx_example_to('211'))
98
+ ofx.parser.should == 'ofx-211-parser'
99
+ end
100
+
101
+ it "should use 211 parser to parse version 220 ofx files" do
102
+ expect(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser')
103
+
104
+ ofx = OFX::Parser::Base.new(ofx_example_to('220'))
105
+ expect(ofx.parser).to eql 'ofx-211-parser'
106
+ end
107
+
62
108
  describe "headers" do
63
109
  it "should have OFXHEADER" do
64
110
  @ofx.headers["OFXHEADER"].should == "100"
@@ -101,23 +147,12 @@ describe OFX::Parser do
101
147
  end
102
148
 
103
149
  it "should parse headers with CR and without LF" do
150
+ header = %{OFXHEADER:100\rDATA:OFXSGML\rVERSION:102\rSECURITY:NONE\rENCODING:USASCII\rCHARSET:1252\rCOMPRESSION:NONE\rOLDFILEUID:NONE\rNEWFILEUID:NONE\r}
151
+ body = open("spec/fixtures/sample.ofx").read.split(/<OFX>/, 2)[1]
152
+ ofx_with_carriage_return = header + "<OFX>" + body
153
+
104
154
  @ofx = OFX::Parser::Base.new(ofx_with_carriage_return)
105
155
  @ofx.headers.size.should be(9)
106
156
  end
107
157
  end
108
-
109
- def ofx_with_carriage_return
110
- header = %{OFXHEADER:100\rDATA:OFXSGML\rVERSION:102\rSECURITY:NONE\rENCODING:USASCII\rCHARSET:1252\rCOMPRESSION:NONE\rOLDFILEUID:NONE\rNEWFILEUID:NONE\r}
111
- body = open("spec/fixtures/sample.ofx").read.split(/<OFX>/, 2)[1]
112
- header + "<OFX>" + body
113
- end
114
-
115
- def ofx_2_example(version)
116
- <<-EndOfx
117
- <?xml version="1.0" encoding="US-ASCII"?>
118
- <?OFX OFXHEADER="200" VERSION="#{version}" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>"
119
- <OFX>
120
- </OFX>
121
- EndOfx
122
- end
123
158
  end
@@ -13,43 +13,43 @@ describe OFX::Transaction do
13
13
  end
14
14
 
15
15
  it "should set amount" do
16
- @transaction.amount.should == BigDecimal('-35.34')
16
+ expect(@transaction.amount).to eql BigDecimal('-35.34')
17
17
  end
18
18
 
19
19
  it "should cast amount to BigDecimal" do
20
- @transaction.amount.class.should == BigDecimal
20
+ expect(@transaction.amount.class).to be BigDecimal
21
21
  end
22
22
 
23
23
  it "should set amount in pennies" do
24
- @transaction.amount_in_pennies.should == -3534
24
+ expect(@transaction.amount_in_pennies).to eql -3534
25
25
  end
26
26
 
27
27
  it "should set fit id" do
28
- @transaction.fit_id.should == "200910091"
28
+ expect(@transaction.fit_id).to eql "200910091"
29
29
  end
30
30
 
31
31
  it "should set memo" do
32
- @transaction.memo.should == "COMPRA VISA ELECTRON"
32
+ expect(@transaction.memo).to eql "COMPRA VISA ELECTRON"
33
33
  end
34
34
 
35
35
  it "should set check number" do
36
- @transaction.check_number.should == "0001223"
36
+ expect(@transaction.check_number).to eql "0001223"
37
37
  end
38
38
 
39
39
  it "should have date" do
40
- @transaction.posted_at.should == Time.parse("2009-10-09 08:00:00 +0000")
40
+ expect(@transaction.posted_at).to eql Time.parse("2009-10-09 08:00:00 +0000")
41
41
  end
42
42
 
43
43
  it 'should have user date' do
44
- @transaction.occurred_at.should == Time.parse("2009-09-09 08:00:00 +0000")
44
+ expect(@transaction.occurred_at).to eql Time.parse("2009-09-09 08:00:00 +0000")
45
45
  end
46
46
 
47
47
  it "should have type" do
48
- @transaction.type.should == :debit
48
+ expect(@transaction.type).to eql :debit
49
49
  end
50
50
 
51
51
  it "should have sic" do
52
- @transaction.sic.should == '5072'
52
+ expect(@transaction.sic).to eql '5072'
53
53
  end
54
54
  end
55
55
 
@@ -59,39 +59,39 @@ describe OFX::Transaction do
59
59
  end
60
60
 
61
61
  it "should set amount" do
62
- @transaction.amount.should == BigDecimal('60.39')
62
+ expect(@transaction.amount).to eql BigDecimal('60.39')
63
63
  end
64
64
 
65
65
  it "should set amount in pennies" do
66
- @transaction.amount_in_pennies.should == 6039
66
+ expect(@transaction.amount_in_pennies).to eql 6039
67
67
  end
68
68
 
69
69
  it "should set fit id" do
70
- @transaction.fit_id.should == "200910162"
70
+ expect(@transaction.fit_id).to eql "200910162"
71
71
  end
72
72
 
73
73
  it "should set memo" do
74
- @transaction.memo.should == "DEPOSITO POUP.CORRENTE"
74
+ expect(@transaction.memo).to eql "DEPOSITO POUP.CORRENTE"
75
75
  end
76
76
 
77
77
  it "should set check number" do
78
- @transaction.check_number.should == "0880136"
78
+ expect(@transaction.check_number).to eql "0880136"
79
79
  end
80
80
 
81
81
  it "should have date" do
82
- @transaction.posted_at.should == Time.parse("2009-10-16 08:00:00 +0000")
82
+ expect(@transaction.posted_at).to eql Time.parse("2009-10-16 08:00:00 +0000")
83
83
  end
84
84
 
85
85
  it "should have user date" do
86
- @transaction.occurred_at.should == Time.parse("2009-09-16 08:00:00 +0000")
86
+ expect(@transaction.occurred_at).to eql Time.parse("2009-09-16 08:00:00 +0000")
87
87
  end
88
88
 
89
89
  it "should have type" do
90
- @transaction.type.should == :credit
90
+ expect(@transaction.type).to eql :credit
91
91
  end
92
92
 
93
93
  it "should have empty sic" do
94
- @transaction.sic.should == ''
94
+ expect(@transaction.sic).to eql ''
95
95
  end
96
96
  end
97
97
 
@@ -101,27 +101,27 @@ describe OFX::Transaction do
101
101
  end
102
102
 
103
103
  it "should set payee" do
104
- @transaction.payee.should == "Pagto conta telefone"
104
+ expect(@transaction.payee).to eql "Pagto conta telefone"
105
105
  end
106
106
 
107
107
  it "should set check number" do
108
- @transaction.check_number.should == "000000101901"
108
+ expect(@transaction.check_number).to eql "000000101901"
109
109
  end
110
110
 
111
111
  it "should have date" do
112
- @transaction.posted_at.should == Time.parse("2009-10-19 12:00:00 -0300")
112
+ expect(@transaction.posted_at).to eql Time.parse("2009-10-19 12:00:00 -0300")
113
113
  end
114
114
 
115
115
  it "should have user date" do
116
- @transaction.occurred_at.should == Time.parse("2009-10-17 12:00:00 -0300")
116
+ expect(@transaction.occurred_at).to eql Time.parse("2009-10-17 12:00:00 -0300")
117
117
  end
118
118
 
119
119
  it "should have type" do
120
- @transaction.type.should == :other
120
+ expect(@transaction.type).to eql :other
121
121
  end
122
122
 
123
123
  it "should have reference number" do
124
- @transaction.ref_number.should == "101.901"
124
+ expect(@transaction.ref_number).to eql "101.901"
125
125
  end
126
126
  end
127
127
 
@@ -131,7 +131,7 @@ describe OFX::Transaction do
131
131
  end
132
132
 
133
133
  it "should set name" do
134
- @transaction.name.should == "Pagto conta telefone"
134
+ expect(@transaction.name).to eql "Pagto conta telefone"
135
135
  end
136
136
  end
137
137
 
@@ -144,22 +144,22 @@ describe OFX::Transaction do
144
144
 
145
145
  it "should return dep" do
146
146
  @transaction = @account.transactions[9]
147
- @transaction.type.should == :dep
147
+ expect(@transaction.type).to eql :dep
148
148
  end
149
149
 
150
150
  it "should return xfer" do
151
151
  @transaction = @account.transactions[18]
152
- @transaction.type.should == :xfer
152
+ expect(@transaction.type).to eql :xfer
153
153
  end
154
154
 
155
155
  it "should return cash" do
156
156
  @transaction = @account.transactions[45]
157
- @transaction.type.should == :cash
157
+ expect(@transaction.type).to eql :cash
158
158
  end
159
159
 
160
160
  it "should return check" do
161
161
  @transaction = @account.transactions[0]
162
- @transaction.type.should == :check
162
+ expect(@transaction.type).to eql :check
163
163
  end
164
164
  end
165
165
 
@@ -176,11 +176,11 @@ describe OFX::Transaction do
176
176
  end
177
177
 
178
178
  it "should set amount" do
179
- @transaction.amount.should == BigDecimal('-11.76')
179
+ expect(@transaction.amount).to eql BigDecimal('-11.76')
180
180
  end
181
181
 
182
182
  it "should set amount in pennies" do
183
- @transaction.amount_in_pennies.should == -1176
183
+ expect(@transaction.amount_in_pennies).to eql -1176
184
184
  end
185
185
  end
186
186
 
@@ -190,12 +190,31 @@ describe OFX::Transaction do
190
190
  end
191
191
 
192
192
  it "should set amount" do
193
- @transaction.amount.should == BigDecimal('47.01')
193
+ expect(@transaction.amount).to eql BigDecimal('47.01')
194
194
  end
195
195
 
196
196
  it "should set amount in pennies" do
197
- @transaction.amount_in_pennies.should == 4701
197
+ expect(@transaction.amount_in_pennies).to eql 4701
198
198
  end
199
199
  end
200
200
  end
201
+
202
+ context "invalid decimal values" do
203
+ before do
204
+ @ofx = OFX::Parser::Base.new("spec/fixtures/cef_malformed_decimal.ofx")
205
+ @parser = @ofx.parser
206
+ end
207
+
208
+ it "should not raise error" do
209
+ expect { @parser.account.transactions }.to_not raise_error
210
+ end
211
+
212
+ it "should return zero in amount" do
213
+ expect(@parser.account.transactions[0].amount).to eql BigDecimal('0.0')
214
+ end
215
+
216
+ it "should return zero in amount_in_pennies" do
217
+ expect(@parser.account.transactions[0].amount_in_pennies).to eql 0
218
+ end
219
+ end
201
220
  end
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,14 @@
1
- require 'ofx_br'
1
+ require "ofx"
2
+ require "byebug"
2
3
 
3
4
  RSpec::Matchers.define :have_key do |key|
4
5
  match do |hash|
5
6
  hash.respond_to?(:keys) &&
6
- hash.keys.is_a?(Array) &&
7
- hash.keys.include?(key)
7
+ hash.keys.kind_of?(Array) &&
8
+ hash.keys.include?(key)
8
9
  end
9
10
  end
11
+
12
+ RSpec.configure do |c|
13
+ c.filter_run_when_matching :focus
14
+ end