Skip to content

Instantly share code, notes, and snippets.

@turboladen
Created July 26, 2013 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turboladen/6091093 to your computer and use it in GitHub Desktop.
Save turboladen/6091093 to your computer and use it in GitHub Desktop.
PhonyRails normalizes phone numbers in such a way that they fail their own validations...
# PhonyRails + Faker
1000.times do
num = PhonyRails.normalize_number(Faker::PhoneNumber.short_phone_number, country_code: 'US')
sizes << num.size
end
sizes.count { |s| s == 9 } # => 22
sizes.count { |s| s == 10 } # => 180
sizes.count { |s| s == 11 } # => 797
# PhonyRails + 10-digit number
1000.times do
num = PhonyRails.normalize_number(rand(1011011000..9999999999).to_s, country_code: 'US')
sizes << num.size
end
sizes.count { |s| s == 9 } # => 15
sizes.count { |s| s == 10 } # => 92
sizes.count { |s| s == 11 } # => 893
# Just Faker
1000.times do
num = Faker::PhoneNumber.short_phone_number
sizes << num.size
end
sizes.count { |s| s == 9 } # => 0
sizes.count { |s| s == 10 } # => 0
sizes.count { |s| s == 11 } # => 0
sizes.count { |s| s == 12 } # => 1000
# Just 10-digit numbers
1000.times do
num = rand(1011011000..9999999999).to_s
sizes << num.size
end
sizes.count { |s| s == 9 } # => 0
sizes.count { |s| s == 10 } # => 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment