|
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 | 58 | }.should raise_error(OFX::UnsupportedFileError) |
48 | 59 | end |
49 | 60 |
|
50 | | - it "uses 102 parser to parse version 100 ofx files" do |
| 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 |
51 | 76 | expect(OFX::Parser::OFX102).to receive(:new).and_return('ofx-102-parser') |
52 | 77 |
|
53 | | - ofx = OFX::Parser::Base.new(ofx_2_example('100')) |
| 78 | + ofx = OFX::Parser::Base.new(ofx_example_to('103')) |
54 | 79 | expect(ofx.parser).to eql 'ofx-102-parser' |
55 | 80 | end |
56 | 81 |
|
57 | | - it "uses 211 parser to parse version 200 ofx files" do |
| 82 | + it "should use 211 parser to parse version 200 ofx files" do |
58 | 83 | expect(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser') |
59 | 84 |
|
60 | | - ofx = OFX::Parser::Base.new(ofx_2_example('200')) |
| 85 | + ofx = OFX::Parser::Base.new(ofx_example_to('200')) |
61 | 86 | ofx.parser.should == 'ofx-211-parser' |
62 | 87 | end |
63 | 88 |
|
64 | 89 | it "should use 211 parser to parse version 202 ofx files" do |
65 | 90 | OFX::Parser::OFX211.stub(:new).and_return('ofx-211-parser') |
66 | | - ofx = OFX::Parser::Base.new(ofx_2_example('202')) |
| 91 | + ofx = OFX::Parser::Base.new(ofx_example_to('202')) |
| 92 | + ofx.parser.should == 'ofx-211-parser' |
| 93 | + end |
| 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')) |
67 | 98 | ofx.parser.should == 'ofx-211-parser' |
68 | 99 | end |
69 | 100 |
|
70 | | - it "uses 211 parser to parse version 220 ofx files" do |
| 101 | + it "should use 211 parser to parse version 220 ofx files" do |
71 | 102 | expect(OFX::Parser::OFX211).to receive(:new).and_return('ofx-211-parser') |
72 | 103 |
|
73 | | - ofx = OFX::Parser::Base.new(ofx_2_example('220')) |
| 104 | + ofx = OFX::Parser::Base.new(ofx_example_to('220')) |
74 | 105 | expect(ofx.parser).to eql 'ofx-211-parser' |
75 | 106 | end |
76 | 107 |
|
|
124 | 155 | @ofx.headers.size.should be(9) |
125 | 156 | end |
126 | 157 | end |
127 | | - |
128 | | - def ofx_2_example(version) |
129 | | - <<-EndOfx |
130 | | -<?xml version="1.0" encoding="US-ASCII"?> |
131 | | -<?OFX OFXHEADER="200" VERSION="#{version}" SECURITY="NONE" OLDFILEUID="NONE" NEWFILEUID="NONE"?>" |
132 | | -<OFX> |
133 | | -</OFX> |
134 | | - EndOfx |
135 | | - end |
136 | 158 | end |
0 commit comments