Faker

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.

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:

Usage

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.

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