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.
- 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.
- 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.
- Installing
- Usage
- Faker::Address
- Faker::Ancient
- Faker::App
- Faker::Avatar
- Faker::Bank
- Faker::Beer
- Faker::Bitcoin
- Faker::Book
- Faker::Boolean
- Faker::Business
- Faker::Cat
- Faker::ChuckNorris
- Faker::Code
- Faker::Color
- Faker::Commerce
- Faker::Company
- Faker::Crypto
- Faker::Date
- Faker::Demographic
- Faker::Educator
- Faker::File
- Faker::Fillmurray
- Faker::Food
- Faker::GameOfThrones
- Faker::Hacker
- Faker::Hipster
- Faker::Internet
- Faker::LordOfTheRings
- Faker::LoremPixel
- Faker::Lorem
- Faker::Music
- Faker::Name
- Faker::Number
- Faker::PhoneNumber
- Faker::Placeholdit
- Faker::Pokemon
- Faker::RockBand
- Faker::SlackEmoji
- Faker::Space
- Faker::StarWars
- Faker::Superhero
- Faker::Team
- Faker::Time
- Faker::TwinPeaks
- Faker::University
- Faker::Vehicle
- Customization
- Contributing
- Contact
- License
gem install faker
Faker::Name.name #=> "Christophe Bartell"
Faker::Internet.email #=> "[email protected]"
Prefix your method call with unique
. For example:
Faker::Name.unique.name # This will return a unique name every time it is called
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
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]
See CONTRIBUTING.md.
Comments and feedback are welcome. Send an email to Benjamin Curtis via the google group.
This code is free to use under the terms of the MIT license.