forked from max-power/bank
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests for Bank::BIC and making valid_format? return a boolean …
…instead of an integer|nil
- Loading branch information
Daniel Mueller
committed
Apr 16, 2014
1 parent
9f3d0db
commit 65de3a8
Showing
3 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require 'spec_helper' | ||
|
||
|
||
describe Bank::BIC do | ||
before do | ||
@bic = Bank::BIC.new('ABNACHZ8XXX') | ||
end | ||
|
||
it 'returns the right bank code' do | ||
@bic.bank_code.must_equal 'ABNA' | ||
end | ||
|
||
it 'returns the right country code' do | ||
@bic.country_code.must_equal 'CH' | ||
end | ||
|
||
it 'returns the right location code' do | ||
@bic.location_code.must_equal 'Z8' | ||
end | ||
|
||
it 'returns the right branch code' do | ||
@bic.branch_code.must_equal 'XXX' | ||
end | ||
|
||
[ 8, 11 ].each do |len| | ||
describe 'x'*len do | ||
it "has a valid length" do | ||
Bank::BIC.new('x'*len).valid_length?.must_equal true | ||
end | ||
end | ||
end | ||
|
||
1.upto(20) do |len| | ||
if len != 8 && len != 11 | ||
describe 'x'*len do | ||
it "has a valid length" do | ||
Bank::BIC.new('x'*len).valid_length?.must_equal false | ||
end | ||
end | ||
end | ||
end | ||
|
||
[ 'UCJAES2MXXX', | ||
'ABAGATWWXXX', | ||
'UCJAES2MXXX' | ||
].each do |code| | ||
describe code do | ||
it "has a valid format" do | ||
Bank::BIC.new(code).valid_format?.must_equal true | ||
end | ||
end | ||
end | ||
|
||
[ | ||
'12341234' | ||
].each do |code| | ||
describe code do | ||
it "has an invalid format" do | ||
Bank::BIC.new(code).valid_format?.must_equal false | ||
end | ||
end | ||
end | ||
|
||
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 |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
|
||
require 'active_model' | ||
require 'bank/iban' | ||
require 'bank/bic' |