Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions spec/ofx/account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,53 @@
end

describe "account" do
it "should return currency" do
it "returns currency" do
expect(@account.currency).to eql "BRL"
end

it "should return bank id" do
it "returns bank id" do
expect(@account.bank_id).to eql "0356"
end

it "should return id" do
it "returns id" do
expect(@account.id).to eql "03227113109"
end

it "should return type" do
it "returns type" do
expect(@account.type).to eql :checking
end

it "should return transactions" do
it "returns transactions" do
expect(@account.transactions).to be_a_kind_of(Array)
expect(@account.transactions.size).to eql 36
end

it "should return balance" do
it "returns balance" do
expect(@account.balance.amount).to eql BigDecimal('598.44')
end

it "should return balance in pennies" do
it "returns balance in pennies" do
expect(@account.balance.amount_in_pennies).to eql 59844
end

it "should return balance date" do
it "returns balance date" do
expect(@account.balance.posted_at).to eql Time.gm(2009,11,1)
end

context "available_balance" do
it "should return available balance" do
it "returns available balance" do
expect(@account.available_balance.amount).to eql BigDecimal('1555.99')
end

it "should return available balance in pennies" do
it "returns available balance in pennies" do
expect(@account.available_balance.amount_in_pennies).to eql 155599
end

it "should return available balance date" do
it "returns available balance date" do
expect(@account.available_balance.posted_at).to eql Time.gm(2009,11,1)
end

it "should return nil if AVAILBAL not found" do
it "returns nil if AVAILBAL not found" do
@ofx = OFX::Parser::Base.new("spec/fixtures/utf8.ofx")
@parser = @ofx.parser
@account = @parser.account
Expand All @@ -69,11 +69,11 @@
@account = @parser.account
end

it "should return id" do
it "returns id" do
expect(@account.id).to eql "XXXXXXXXXXXX1111"
end

it "should return currency" do
it "returns currency" do
expect(@account.currency).to eql "USD"
end
end
Expand All @@ -84,7 +84,7 @@
@account = @parser.account
end

it "should return nil for date balance" do
it "returns nil for date balance" do
expect(@account.balance.posted_at).to be_nil
end
end
Expand All @@ -94,10 +94,10 @@
@ofx = OFX::Parser::Base.new("spec/fixtures/bradesco.ofx")
@parser = @ofx.parser
end
it "should not raise error when balance has date zero" do
it "does not raise error when balance has date zero" do
expect { @parser.account.balance }.to_not raise_error
end
it "should return NIL in balance.posted_at when balance date is zero" do
it "returns NIL in balance.posted_at when balance date is zero" do
expect(@parser.account.balance.posted_at).to be_nil
end
end
Expand All @@ -109,20 +109,20 @@
@account = @parser.account
end

it "should return balance" do
it "returns balance" do
expect(@account.balance.amount).to eql BigDecimal('348.29')
end

it "should return balance in pennies" do
it "returns balance in pennies" do
expect(@account.balance.amount_in_pennies).to eql 34829
end

context "available_balance" do
it "should return available balance" do
it "returns available balance" do
expect(@account.available_balance.amount).to eql BigDecimal('2415.87')
end

it "should return available balance in pennies" do
it "returns available balance in pennies" do
expect(@account.available_balance.amount_in_pennies).to eql 241587
end
end
Expand Down
20 changes: 10 additions & 10 deletions spec/ofx/ofx102_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,37 @@
@parser = @ofx.parser
end

it "should have a version" do
it "has a version" do
expect(OFX::Parser::OFX102::VERSION).to eql "1.0.2"
end

it "should set headers" do
it "sets headers" do
expect(@parser.headers).to eql @ofx.headers
end

it "should trim trailing whitespace from headers" do
it "trims trailing whitespace from headers" do
headers = OFX::Parser::OFX102.parse_headers("VERSION:102 ")
expect(headers["VERSION"]).to eql "102"
end

it "should set body" do
it "sets body" do
expect(@parser.body).to eql @ofx.body
end

it "should set account" do
it "sets account" do
expect(@parser.account).to be_a_kind_of(OFX::Account)
end

it "should set account" do
it "sets sign_on" do
expect(@parser.sign_on).to be_a_kind_of(OFX::SignOn)
end

it "should set statements" do
it "sets statements" do
expect(@parser.statements.size).to eql 1
expect(@parser.statements.first).to be_a_kind_of(OFX::Statement)
end

it "should know about all transaction types" do
it "knows about all transaction types" do
valid_types = [
'CREDIT', 'DEBIT', 'INT', 'DIV', 'FEE', 'SRVCHG', 'DEP', 'ATM', 'POS', 'XFER',
'CHECK', 'PAYMENT', 'CASH', 'DIRECTDEP', 'DIRECTDEBIT', 'REPEATPMT', 'OTHER', 'IN', 'OUT'
Expand All @@ -50,14 +50,14 @@

describe "#build_date" do
context "without a Time Zone" do
it "should default to GMT" do
it "defaults to GMT" do
expect(@parser.send(:build_date, "20170904")).to eql Time.gm(2017, 9, 4)
expect(@parser.send(:build_date, "20170904082855")).to eql Time.gm(2017, 9, 4, 8, 28, 55)
end
end

context "with a Time Zone" do
it "should returns the correct date" do
it "returns the correct date" do
expect(@parser.send(:build_date, "20150507164333[-0300:BRT]")).to eql Time.new(2015, 5, 7, 16, 43, 33, "-03:00")
expect(@parser.send(:build_date, "20180507120000[0:GMT]")).to eql Time.gm(2018, 5, 7, 12)
expect(@parser.send(:build_date, "20170904082855[-3:GMT]")).to eql Time.new(2017, 9, 4, 8, 28, 55, "-03:00")
Expand Down
20 changes: 10 additions & 10 deletions spec/ofx/ofx211_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@
@parser = @ofx.parser
end

it "should have a version" do
it "has a version" do
expect(OFX::Parser::OFX211::VERSION).to eql "2.1.1"
end

it "should set headers" do
it "sets headers" do
expect(@parser.headers).to eql @ofx.headers
end

it "should set body" do
it "sets body" do
expect(@parser.body).to eql @ofx.body
end

it "should set account" do
it "sets account" do
expect(@parser.account).to be_a_kind_of(OFX::Account)
end

it "should set account" do
it "sets sign_on" do
expect(@parser.sign_on).to be_a_kind_of(OFX::SignOn)
end

it "should set accounts" do
it "sets accounts" do
expect(@parser.accounts.size).to eql 2
end

it "should set statements" do
it "sets statements" do
expect(@parser.statements.size).to eql 2
expect(@parser.statements.first).to be_a_kind_of(OFX::Statement)
end
Expand All @@ -43,7 +43,7 @@
@t = @parser.accounts[0].transactions[0]
end

it "should contain the correct values" do
it "contains the correct values" do
expect(@t.amount).to eql BigDecimal('-80')
expect(@t.fit_id).to eql "219378"
expect(@t.memo).to be_empty
Expand All @@ -57,7 +57,7 @@
@t = @parser.accounts[1].transactions[0]
end

it "should contain the correct values" do
it "contains the correct values" do
expect(@t.amount).to eql BigDecimal('-23')
expect(@t.fit_id).to eql "219867"
expect(@t.memo).to be_empty
Expand All @@ -71,7 +71,7 @@
@t = @parser.accounts[1].transactions[1]
end

it "should contain the correct values" do
it "contains the correct values" do
expect(@t.amount).to eql BigDecimal('350')
expect(@t.fit_id).to eql "219868"
expect(@t.memo).to be_empty
Expand Down
Loading