Technology moves fast! ⚑ Don't get left behind.🚢 Subscribe to our mailing list to keep up with latest and greatest in open source projects! πŸ†


Subscribe to our mailing list

faker

A library for generating fake data such as names, addresses, and phone numbers.

Subscribe to updates I use faker


Statistics on faker

Number of watchers on Github 6260
Number of open issues 193
Average time to close an issue 9 days
Main language Ruby
Average time to merge a PR 9 days
Open pull requests 243+
Closed pull requests 77+
Last commit over 1 year ago
Repo Created over 10 years ago
Repo Last Updated over 1 year ago
Size 2.8 MB
Organization / Authorstympy
Contributors178
Page Updated
Do you use faker? Leave a review!
View open issues (193)
View faker activity
View on github
Fresh, new opensource launches πŸš€πŸš€πŸš€
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating faker for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Faker Build Status Gem Version

This gem is a port of Perl's Data::Faker library that generates fake data.

It comes in very handy for taking screenshots (taking screenshots for my project, Catch the Best was the original impetus for the creation of this gem), having real-looking test data, and having your database populated with more than one or two records while you're doing development.

NOTE

  • While Faker generates data at random, returned values are not guaranteed to be unique by default. You must explicity specify when you require unique values, see details. Values also can be deterministic if you use the deterministic feature, see details
  • This is the master branch of Faker and may contain changes that are not yet released. Please refer the README of your version for the available methods. List of all versions is available here.

Contents

Installing

gem install faker

Note: if you are getting a uninitialized constant Faker::[some_class] error, your version of the gem is behind the one documented here. To make sure that your gem is the one documented here, change the line in your gemfile to:

gem 'faker', :git => 'https://github.com/stympy/faker.git', :branch => 'master'

Usage

require 'faker'

Faker::Name.name      #=> "Christophe Bartell"

Faker::Internet.email #=> "kirsten.greenholt@corkeryfisher.info"

Ensuring unique values

Prefix your method call with unique. For example:

Faker::Name.unique.name # This will return a unique name every time it is called

If too many unique values are requested from a generator that has a limited number of potential values, a Faker::UniqueGenerator::RetryLimitExceeded exception may be raised. It is possible to clear the record of unique values that have been returned, for example between tests.

Faker::Name.unique.clear # Clears used values for Faker::Name
Faker::UniqueGenerator.clear # Clears used values for all generators

Deterministic Random

Faker supports seeding of its pseudo-random number generator (PRNG) to provide deterministic output of repeated method calls.

Faker::Config.random = Random.new(42)
Faker::Company.bs #=> "seize collaborative mindshare"
Faker::Company.bs #=> "engage strategic platforms"
Faker::Config.random = Random.new(42)
Faker::Company.bs #=> "seize collaborative mindshare"
Faker::Company.bs #=> "engage strategic platforms"

Faker::Config.random = nil # seeds the PRNG using default entropy sources
Faker::Config.random.seed #=> 185180369676275068918401850258677722187
Faker::Company.bs #=> "cultivate viral synergies"

Customization

Since you may want to make addresses and other types of data look different depending on where in the world you are (US postal codes vs. UK postal codes, for example), Faker uses the I18n gem to store strings (like state names) and formats (US postal codes are NNNNN while UK postal codes are AAN NAA), allowing you to get different formats by switching locales. Just set Faker::Config.locale to the locale you want, and Faker will take care of the rest.

If your locale doesn't already exist, create it in the \lib\locales\ directory and you can then override or add elements to suit your needs. See more about how to use locales here


en-au-ocker:
  faker:
    name:
      # Existing faker field, new data
      first_name: [Charlotte, Ava, Chloe, Emily]

      # New faker fields
      ocker_first_name: [Bazza, Bluey, Davo, Johno, Shano, Shazza]
      region: [South East Queensland, Wide Bay Burnett, Margaret River, Port Pirie, Gippsland, Elizabeth, Barossa]

Contributing

See CONTRIBUTING.md.

Contact

Comments and feedback are welcome. Send an email to Benjamin Curtis via the google group.

License

This code is free to use under the terms of the MIT license.

faker open issues Ask a question     (View All Issues)
  • over 2 years Base#numerify generating phone numbers and other number fields with a weird format
  • over 2 years assert Faker::Internet.email.match(/.+@[^.].+\.\w+/) fails randomly
  • over 2 years Incorrect HSL color format
  • over 2 years Can we add the #Hacktoberfest label for pull requests this month
  • over 2 years Faker::Boolean.boolean error
  • almost 3 years [Feature Request] AWS EC2 Data
  • almost 3 years [Feature Request] Add full address
  • almost 3 years Config for adding format restriction.
  • almost 3 years Faker::Food not found
  • almost 3 years Fix seed for random values
  • almost 3 years README alphabetical order of Usage
  • almost 3 years At which point do we break off functionality?
  • almost 3 years Time zone abbreviation
  • almost 3 years Markdown/HTML Support
  • almost 3 years ruby 2.3.1 rails 5
  • almost 3 years How to avoid special characters in faker string field
  • about 3 years Suggestion: Convert parameters to keyword arguments
  • about 3 years Feature Request: Move locales to an external directory
  • about 3 years Update WIKI and clean README
  • about 3 years Add Demographic Data
  • about 3 years Sectors/areas for University and compaies
  • about 3 years Add country code
  • over 3 years How do I include Faker's customisation without changing the files in the gem?
  • over 3 years Faker::Time::between doesn't respect requested period
  • over 3 years wysiwyg conent
  • over 3 years OmniAuth ready responses
  • over 3 years Faker::PhoneNumber.cell_phone not enforcing locale
  • over 3 years Faker::BankAccount
  • over 3 years Add Middle Name Field to Faker::Name
  • over 3 years Faker expects ':en' locale to be present
faker open pull requests (View All Pulls)
  • improved the swedish locale, added test for it
  • Create Faker::BankAccount
  • Make Faker::Number return integers and floats instead of strings
  • First attempt to replace test-unit with rspec
  • adding test for first and last name as well
  • Ref 490, adding name_with_middle option
  • Ref #487 added middle_name
  • Chore/fix style violations
  • Added Faker::Job with title, field and key skills
  • Added both image and video using the google-search gem.
  • renamed the license and changelog files
  • Support https url scheme (add Faker::Internet.secure_url)
  • Fixing Faker::Book.author issue
  • Remove Eichmann surname
  • Add method to generate twitter handlle
  • Added Faker::name.initials generator.
  • Fix bug when password always get min length
  • Created a class which contains fake customer data
  • Fixing the I18n problem that was preventing the tests to run refs #278
  • Random diff is added to the min to generate password lengths
  • Add lorempixel image support
  • Added support for random boolean numbers
  • Multibute chars support for regexps and domain name generation method improvement.
  • Faker::Internet#uri
  • Added game_of_thrones names to en.yml, a test, and updated documentation.
  • Added range functionality to Faker::Commerce.price
  • updated ja locale and added ja test
  • chuck norris facts introduced
  • Web Safe Color Hex Code
  • Added a format to Time between,backward and forward to return a string formatted for US users.
  • Extend library with Faker::Wine.
  • Fix time period test that could result in a flake test within 15 days…
  • Fix Faker::Internet.safe_email makes bad emails for some locales #272
  • Add msisdn format to phone_number
  • [feature] - Support phone code in phone number module
  • [feature] - Support currency code, name generate
  • Get "invalid date (ArgumentError)" when generating a birthday at 29 Feb 2016
  • Add gender to name generator
  • Integrate Lorempixel
  • Added Faker::Job
  • ABN and VIN extension
  • Added File functionality
  • Update and improve locale de.yml
  • Addition of timecode
  • Unit tests for en-IND locale
  • Add Yoda quotes
  • Removed "cum" and "cumque" words from list of generated words
  • Readme images
  • Adds Music keys and instruments
  • New examples and tests in french locale, new format : cell phone
  • [29 Feb bugfix] Call birthday for leap year
  • Improved FI locale unit test coverage
  • Improve lorem
  • Added Question/Questions to Faker::Lorem
  • Extended lib to include Space option.
  • Added final newline to beer.rb
  • Changed quotes in app.rb
  • Improve way to generate IP address
  • Adds private ips method to Internet
  • Improved de-AT unit tests
  • Add educational_email for .edu addresses
  • Add Faker::Cat to documentation
  • Changed quotes in color.rb
  • Convert to keyword arguments
  • Solved Issue #623
  • Refactor Luhn Checksum
  • Added en-SG unit tests
  • Styles fix
  • add german commerce translations
  • Add support for dutch university names
  • Added default country check to en-PAK unit tests
  • Add Lord Of The Rings
  • Added even method to Luhn algorithm
  • Add more names to pt-BR
  • Added time_zone_abbr into Faker::Address
  • Add Nigerian locale to locales
  • Nation: This is for Nationality and National language of different Country
  • Convert hashes to hash with indifferent access for rails
  • Refactored code
  • Fix Mr. Mime, Remove nil and Add Mew
  • Adding ability to set URL scheme to Internet#url
  • Added feature to generate random exercises.
  • Fix extra spaces in en.yml
  • Sorted README by module name
  • Eliminate and prevent leading and trailing white space
  • Fix for memory overflow error Issue: #478
  • Add Taiwan province to china
  • Added Faker::RockBand
  • Added unit tests to es-MX locale
  • Adding a pet module
  • Puerto Rico is a territory, not a country, so shouldn't be in the list of countries/country codes.
  • Added default country test to en-AU locale
  • Fixed incorrect locale configuration
  • Add AdvertiserId Module
  • Add pokemon
  • allow Time.between to receive `:between` to deliver time in range
  • Add password_confirmation method to Faker::Internet
  • Added Fillmurray to Faker
  • Food
  • Added charcaters and houses data for game of thrones in en.yml
  • add Faker::Commerce.promotion_code
  • Add functionality for getting names without apostrophe
  • Fixed the inaccurate swedish organization number generator
  • Fix typos in brazilian portuguese countries translations
  • Fix typo in 'Secondary'
  • Add Faker::TwinPeaks
  • Changed quotes in food.rb
  • Added type checks to PL unit test
  • Fix Faker::Educator "secondary" spelling
  • Refute blank
  • Changed specie to species and species to species_list in StarWars. Ma…
  • Fix Faker::Vehicle Array Access
  • Alphabetized README.md
  • adds meteorite to Faker::Space
  • fixed typo in secondary_school
  • Improve Address.postcode example to reflect actual output
  • Add The Simpsons
  • adding some extra generators for mobile and domains
  • add automotive data
  • Add Country Code for Phone Numbers and Cellphones
  • Added en-ZA unit tests
  • added indonesian locale
  • Added dragons to the Game of Throne universe.
  • Tweak es-MX locale data for addresses
  • Add Game of Thrones quotes
  • adds Faker::Artist.name
  • Add Social Security Number Faker
  • Resolve warnings during tests
  • Add chords to music
  • Add major and minor keys to music
  • Random words to add should be 0
  • Use Random::DEFAULT instead of Random.new.rand / SecureRandom
  • Added Korean unit tests
  • it.yml: name.suffix: replace list with empty string, to make it consi…
  • fix german university name generation
  • fr.yml: remove 13 after lille
  • Add Normal (Gaussian) distribution to Faker::Number
  • Update educator.rb
  • Some Turkish Translations #1
  • Add some german translations ...
  • Add method for ensuring unique values
  • Delete unneeded line for Faker::Internet.password
  • Add Mew to Pokemon::Name
  • Update docs to make it clearer what args to Lorem.sentence and Lorem.paragraph do
  • Exclude multicast
  • Add optional https urls
  • Creates tests for Address#zip_code
  • Creates Address#full_address customizable by locale
  • Improves readability of Hipster#resolve.
  • Changes Hipster methods to use named parameters to improve readability.
  • Improves test suites for a couple of classes
  • Add Faker for Famous Last Words
  • Create a Dessert faker
  • Added material to the Commerce docs.
  • Add Faker::TheFreshPrinceOfBelAir
  • Add Japanese lorem words to locale
  • Adds Faker::Witcher
  • Adds Faker::Measurement
  • Added Spanish Organization Number
  • Silicon valley
  • Adds chilean RUT (social security number equivalent)
  • World of Warcraft Characters and Quotes
  • add Faker::String
  • Adding city name template for pt-BR
  • Add Canada SIN generator in Faker::Code
  • fix intermittent error "special chars" not being used
  • Partial fix for Faker::Date.birthday
  • Adds 'Quotes' to books in lib/locales/fr.yml
  • Added area and exchange code features for en-CA
  • [Resolved] #843 Russian Local issue
  • Adds Blog: Author, Post, Comment
  • LoremFlickr support
  • Faker::Lorem.multibyte for multibyte chars
  • 357 generating money amounts
  • Modify Faker::Commerce.price, Fix #806
  • Modify Faker::Educator, Fix #576
  • Adds support for the British National Health Service (NHS) fake data
  • Bheim6 electrical component spike
  • Adding country code + minor locale updates
  • Fixing special chars addition in passwords.
  • add Hogwarts and Ilvermorny houses to Harry Potter faker
  • Rubocop + fixes
  • Add metric measurement to the Faker::Food
  • Alphabetizing `en.yml` file
  • 873 fix birthday
  • Made the documentation more consistent
  • Add Address.mailing_address method. Add tests for Faker::Address. Fix…
  • Update commerce documentation
  • Adds Faker::Fallout
  • fixed tests method name for TestFakerLeagueOfLegends
  • Vehicle faker
  • Added SingularSiegler quotes
  • Use ruby syntax highlighting in Omniauth doc
  • Added Faker::Community
  • Fix ranges for Brazilian zip codes
  • Fix formatting for Brazilian phone and cell phone numbers
  • Better docs for Faker::Food.description
  • Added Ukrainian entries to yml
  • Add Faker::Cosmere
  • Added Princess Bride
  • Update Faker::Dessert
  • Add tokens to Faker::Stripe
  • Adds turkish phone number formats and test.
  • Fix inconsistent capitalization in dishes, ingredients and spices, and some other small issues under 'food'
  • Add czech_organisation_number support
  • Escape quote `'` within double quote
  • Add paragraph_by_chars() functionality
  • Markdown sandwich
  • Markdown exclude method
  • Add Invoice class to generate valid bank slip references
  • Fallback translation without available locales enforcement
  • Converts LoremPixel's arguments from positional to named.
  • refactor method_missing method
  • use metric_ keys for metric measurements
  • Added an Ethereum public address generator
  • [WIP] Count elements in collections
  • [WM] Add Faker::Cannabis class
  • [docs] Specify version number each class was introduced
  • WIP Add counts for faker elements in the documentation
  • improving ip_address generation/validation
  • Adding Industry Segments Class
  • Add Spanish citizen id and docs
  • Update company docs
  • Restaurants
  • Added polish_register_of_national_economy and polish_taxpayer_identification_number
  • Missing i18n jobs fix
  • Add method for coffee intensifier
  • Add Estonian and Latvian locales
  • add hero 26
  • Update Faker::Omniauth to use Faker::Internet to create names and email addresses (+ bug-fix in Faker::Internet).
  • Modify Modify Faker::Internet.slug
  • Added documentation for dumb and dumber
  • Test against latest Ruby versions
  • Fix I18n 0.9.3 compatibility
  • add scheme documentation for Faker::Internet.url
  • Add more content, correct a couple of misspellings.
  • Add Faker::TheITCrowd
  • Add league of legends roles and lanes
  • fix(currency-test): add whitespace in name regex
  • Add Faker::NewGirl
  • Make sure Omniauth generates valid emails
  • Added Japanese entries to yml
  • JSON Generator Add Faker::Json with tests and documentation
faker questions on Stackoverflow (View All Questions)
  • Should we be using Faker in Rails Factories?
  • How faker generate a yaml list that browser understand?
  • Generating test data of incremental dates faker laravel
  • laravel testing with faker big text
  • NameError: uninitialized constant Faker ; Ruby on Rails
  • Faker gem: possible to seed with stylized text?
  • Generating Paperclip image uploads with fake data - Ruby on Rails Populator / Faker Gems
  • Change Faker Locale in Laravel 5.2
  • Populate tables with Faker
  • php fzaninotto Faker - How to Generate Only 5 Digit Zip Code?
  • applying a function to faker
  • Generating test data with Faker
  • Expediency of using Faker in Minitest fixtures
  • Faker Package, Database Seeder Issues
  • WATIR: faker gem not working
  • Unexpected tIDENTIFIER using Faker gem
  • Faker is producing duplicate data when used in factory_girl
  • How to get future date in Faker
  • how to get city inside a especific country with Faker extension
  • PHP Faker. How to create N unique words?
  • faker (python) randomizes in shell, but not in DjangoModelFactory object
  • Parse error in Faker for Laravel 5.0
  • Set MySQL Timestamp field using Faker
  • Deployment on Laravel Forge throwing faker not found Exception
  • FactoryGirl + Faker - same data being generated for every object in db seed data
  • how to use biasedNumberBetween faker?
  • Faker Gem creating fake picture not working
  • How to install faker module on python (windows 7)
  • Rspec Factory Girl faker does not accept column
  • Rspec + FactoryGirl + Faker tests failing randomly
faker list of languages used
Other projects in Ruby