forked from viafintech/camt_parser
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some more specs, some spec refactoring
- Loading branch information
Showing
14 changed files
with
159 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::AccountBalance do | ||
let(:camt) { CamtParser::File.parse('spec/fixtures/valid_example.xml') } | ||
let(:statements) { camt.statements } | ||
let(:ex_stmt) { camt.statements[0] } | ||
subject { ex_stmt.opening_balance } | ||
|
||
specify { expect(subject.currency).to eq "EUR" } | ||
specify { expect(subject.date).to eq Date.new(2013,12,27) } | ||
specify { expect(subject.sign).to eq 1 } | ||
specify { expect(subject.credit?).to be_truthy } | ||
specify { expect(subject.amount).to eq BigDecimal.new("33.06") } | ||
specify { expect(subject.amount_in_cents).to eq 3306 } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::Account do | ||
let(:camt) { CamtParser::File.parse('spec/fixtures/valid_example.xml') } | ||
let(:statements) { camt.statements } | ||
let(:ex_stmt) { camt.statements[0] } | ||
let(:account) { ex_stmt.account } | ||
|
||
it { expect(account.iban).to eq("DE14740618130000033626") } | ||
it { expect(account.iban).to eq(account.account_number) } | ||
it { expect(account.iban).to eq(account.source) } | ||
it { expect(account.bic).to eq("GENODEF1PFK") } | ||
it { expect(account.bank_name).to eq("VR-Bank Rottal-Inn eG") } | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::Base do | ||
it "parses the group_header and the statements" do | ||
expect(CamtParser::Format053::GroupHeader).to receive(:new).and_call_original | ||
expect(CamtParser::Format053::Statement).to receive(:new).and_call_original | ||
camt = CamtParser::File.parse 'spec/fixtures/valid_example.xml' | ||
expect(camt.group_header).to_not eq(nil) | ||
expect(camt.statements).to_not eq([]) | ||
|
||
context 'initialization' do | ||
after do | ||
CamtParser::File.parse 'spec/fixtures/valid_example.xml' | ||
end | ||
|
||
it { expect(CamtParser::Format053::GroupHeader).to receive(:new).and_call_original } | ||
it { expect(CamtParser::Format053::Statement).to receive(:new).and_call_original } | ||
end | ||
|
||
let(:camt) { CamtParser::File.parse 'spec/fixtures/valid_example.xml' } | ||
it { expect(camt.group_header).to_not be_nil } | ||
it { expect(camt.statements).to_not eq([]) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::Creditor do | ||
let(:camt) { CamtParser::File.parse('spec/fixtures/valid_example.xml') } | ||
let(:statements) { camt.statements } | ||
let(:ex_stmt) { camt.statements[0] } | ||
let(:entries) { ex_stmt.entries } | ||
let(:ex_entry) { ex_stmt.entries[0] } | ||
let(:creditor) { ex_entry.creditor } | ||
|
||
it { expect(creditor.name).to eq("Testkonto Nummer 2") } | ||
it { expect(creditor.iban).to eq("DE09300606010012345671") } | ||
it { expect(creditor.bic).to eq("DAAEDEDDXXX") } | ||
it { expect(creditor.bank_name).to eq("Bank") } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::Debitor do | ||
let(:camt) { CamtParser::File.parse('spec/fixtures/valid_example.xml') } | ||
let(:statements) { camt.statements } | ||
let(:ex_stmt) { camt.statements[0] } | ||
let(:entries) { ex_stmt.entries } | ||
let(:ex_entry) { ex_stmt.entries[0] } | ||
let(:debitor) { ex_entry.debitor } | ||
|
||
it { expect(debitor.name).to eq("Wayne Enterprises") } | ||
it { expect(debitor.iban).to eq("DE24302201900609832118") } | ||
it { expect(debitor.bic).to eq("DAAEDEDDXXX") } | ||
it { expect(debitor.bank_name).to eq("") } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::Entry do | ||
let(:camt) { CamtParser::File.parse('spec/fixtures/valid_example.xml') } | ||
let(:statements) { camt.statements } | ||
let(:ex_stmt) { camt.statements[0] } | ||
let(:entries) { ex_stmt.entries } | ||
let(:ex_entry) { ex_stmt.entries[0] } | ||
|
||
specify { expect(entries).to all(be_kind_of(described_class)) } | ||
|
||
context '#amount' do | ||
specify { expect(ex_entry.amount).to be_kind_of(BigDecimal) } | ||
specify { expect(ex_entry.amount).to eq(BigDecimal.new('2')) } | ||
specify { expect(ex_entry.amount_in_cents).to eq(200) } | ||
end | ||
|
||
specify { expect(ex_entry.currency).to eq('EUR') } | ||
specify { expect(ex_entry.value_date).to be_kind_of(Date) } | ||
specify { expect(ex_entry.value_date).to eq(Date.new(2013, 12, 27)) } | ||
specify { expect(ex_entry.booking_date).to be_kind_of(Date) } | ||
specify { expect(ex_entry.booking_date).to eq(Date.new(2013, 12, 27)) } | ||
specify { expect(ex_entry.creditor).to be_kind_of(CamtParser::Format053::Creditor) } | ||
specify { expect(ex_entry.debitor).to be_kind_of(CamtParser::Format053::Debitor) } | ||
specify { expect(ex_entry.remittance_information).to eq("TEST BERWEISUNG MITTELS BLZUND KONTONUMMER - DTA") } | ||
specify { expect(ex_entry.additional_information).to eq("Überweisungs-Gutschrift; GVC: SEPA Credit Transfer (Einzelbuchung-Haben)") } | ||
specify { expect(ex_entry.debit?).to eq(true) } | ||
specify { expect(ex_entry.credit?).to eq(false) } | ||
specify { expect(ex_entry.sign).to eq(-1) } | ||
|
||
specify { expect(ex_entry.name).to eq("Testkonto Nummer 2") } | ||
specify { expect(ex_entry.iban).to eq("DE09300606010012345671") } | ||
specify { expect(ex_entry.bic).to eq("DAAEDEDDXXX") } | ||
specify { expect(ex_entry.swift_code).to eq("NTRF") } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,21 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Format053::GroupHeader do | ||
it "parses the GroupHeader" do | ||
camt = CamtParser::File.parse 'spec/fixtures/valid_example.xml' | ||
group_header = camt.group_header | ||
expect(group_header.class).to eq(described_class) | ||
expect(group_header.message_id).to eq("053D2013-12-27T22:05:03.0N130000005") | ||
expect(group_header.creation_date_time.class).to eq(Time) | ||
expect(group_header.message_pagination.class).to eq(CamtParser::Format053::MessagePagination) | ||
expect(group_header.additional_information).to eq(nil) | ||
end | ||
let(:camt) { CamtParser::File.parse 'spec/fixtures/valid_example.xml' } | ||
let(:group_header) { camt.group_header } | ||
|
||
specify { expect(group_header).to be_kind_of(described_class) } | ||
specify { expect(group_header.message_id).to eq("053D2013-12-27T22:05:03.0N130000005") } | ||
specify { expect(group_header.creation_date_time).to be_kind_of(Time) } | ||
specify { expect(group_header.message_pagination).to be_kind_of(CamtParser::Format053::MessagePagination) } | ||
specify { expect(group_header.additional_information).to eq("") } | ||
end | ||
|
||
describe CamtParser::Format053::MessagePagination do | ||
it "parses the MessagePagination information" do | ||
camt = CamtParser::File.parse 'spec/fixtures/valid_example.xml' | ||
message_pagination = camt.group_header.message_pagination | ||
expect(message_pagination.class).to eq(described_class) | ||
expect(message_pagination.page_number).to eq(1) | ||
expect(message_pagination.last_page?).to eq(true) | ||
end | ||
let(:camt) { CamtParser::File.parse 'spec/fixtures/valid_example.xml' } | ||
let(:message_pagination) { camt.group_header.message_pagination } | ||
|
||
specify { expect(message_pagination).to be_kind_of(described_class) } | ||
specify { expect(message_pagination.page_number).to eq(1) } | ||
specify { expect(message_pagination.last_page?).to be_truthy } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'spec_helper' | ||
|
||
describe CamtParser::Misc do | ||
let(:dot_value) { "30.12" } | ||
let(:comma_value) { "30,12" } | ||
|
||
context '#to_amount_in_cents' do | ||
specify { expect(described_class.to_amount_in_cents(dot_value)).to be_kind_of(Fixnum) } | ||
specify { expect(described_class.to_amount_in_cents(dot_value)).to eq(3012) } | ||
specify { expect(described_class.to_amount_in_cents(comma_value)).to eq(3012) } | ||
end | ||
|
||
context '#to_amount' do | ||
specify { expect(described_class.to_amount(dot_value)).to be_kind_of(BigDecimal) } | ||
specify { expect(described_class.to_amount(dot_value)).to eq(30.12) } | ||
specify { expect(described_class.to_amount(comma_value)).to eq(30.12) } | ||
end | ||
end |