Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bank account length #1477

Merged
merged 1 commit into from
Dec 8, 2018
Merged
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
8 changes: 6 additions & 2 deletions lib/faker/default/bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ class Bank < Base
flexible :bank

class << self
def account_number(digits = 11)
rand.to_s[2..digits]
def account_number(digits = 10)
output = ''

output += rand.to_s[2..-1] while output.length < digits

output[0...digits]
end

def iban(country_code = 'GB')
Expand Down
4 changes: 4 additions & 0 deletions test/faker/default/test_faker_bank.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def test_routing_number_with_format

def test_account_number
assert Faker::Bank.account_number.match(/\d{10}/)

assert Faker::Bank.account_number(12).match(/\d{12}/)

assert Faker::Bank.account_number(100).match(/\d{100}/)
end

def test_name
Expand Down