stympy/faker — pull request #133 by acurley (2013-08-15 21:43:13+00:00)
Title: Create Valid US Phone Numbers

Closes #132

This change was required because Faker produced phone numbers which were considered invalid by Phony, a gem for validating phone numbers. Given that my User class implemented validations on phone numbers, my CI was failing often due to Faker creating invalid phone numbers.

Rather than creating phone number through gsub of "#", a user can now set the locale to :en-us and take advantage of valid area and exchange codes for the US.

In this pull request I:
* Added phone_number area_codes, exchange_codes in en-us.yml
* Changed the phone_number.formats YAML configuration in en-us.yml
* Added methods in Faker::PhoneNumber to provide #parse with area_codes, exchange_codes and subscriber_numbers. These methods will return nil if the I18n translation is not present.
* Had to amend Faker::Base#parse to accommodate optional leading parentheses.
* Attend test for new methods and validate output of #phone_number against a regex which implements the NANP standard.