spec/account_spec.rb in banktools-se-0.3.0 vs spec/account_spec.rb in banktools-se-0.4.0
- old
+ new
@@ -2,17 +2,15 @@
require "spec_helper"
require "banktools-se"
describe BankTools::SE::Account do
-
it "should initialize" do
BankTools::SE::Account.new("foo").should be_a(BankTools::SE::Account)
end
describe "#valid?" do
-
it "should be true with no errors" do
account = BankTools::SE::Account.new("foo")
account.stub(:errors).and_return([])
account.should be_valid
end
@@ -20,11 +18,10 @@
it "should be false with errors" do
account = BankTools::SE::Account.new("foo")
account.stub(:errors).and_return([:error])
account.should_not be_valid
end
-
end
describe "#errors" do
[
"1100-0000000", # Nordea.
@@ -105,42 +102,36 @@
it "should include :unknown_clearing_number if the clearing number is unknown" do
BankTools::SE::Account.new("10000000009").errors.should include(BankTools::SE::Errors::UNKNOWN_CLEARING_NUMBER)
BankTools::SE::Account.new("11000000007").errors.should_not include(BankTools::SE::Errors::UNKNOWN_CLEARING_NUMBER)
end
-
end
describe "#bank" do
-
it "should return the bank for the current clearing number" do
BankTools::SE::Account.new("11000000007").bank.should == "Nordea"
BankTools::SE::Account.new("11550000001").bank.should == "Nordea"
BankTools::SE::Account.new("11990000009").bank.should == "Nordea"
BankTools::SE::Account.new("12000000005").bank.should == "Danske Bank"
end
it "should return nil for unknown clearing numbers" do
BankTools::SE::Account.new("10000000009").bank.should be_nil
end
-
end
describe "#clearing_number" do
-
it "should be the first four digits" do
BankTools::SE::Account.new("12345678").clearing_number.should == "1234"
end
it "should be the first five digits if there is a clearing number checksum" do
BankTools::SE::Account.new("8000-2-0000000000").clearing_number.should == "8000-2"
end
-
end
describe "#serial_number" do
-
it "should be the digits after the first four digits" do
BankTools::SE::Account.new("12345678").serial_number.should == "5678"
end
it "should be the digits after the first five digits if there is a clearing number checksum" do
@@ -149,14 +140,16 @@
it "should be the empty string if there aren't enough numbers" do
BankTools::SE::Account.new("12").serial_number.should == ""
end
+ it "should manage pre-zerofilled account numbers" do
+ BankTools::SE::Account.new("8000-2-0800000002").should be_valid
+ end
end
describe "#normalize" do
-
it "should normalize to clearing number dash serial number" do
account = BankTools::SE::Account.new("11000000007").normalize.should == "1100-0000007"
end
it "should keep any Swedbank/Sparbanker clearing checksum" do
@@ -169,9 +162,7 @@
it "should prepend zeroes to the serial number if necessary" do
BankTools::SE::Account.new("8000-2-80000003").normalize.should == "8000-2-0080000003"
BankTools::SE::Account.new("8000-2-8000000003").normalize.should == "8000-2-8000000003"
end
-
end
-
end