Post by Peter Cooper on December 3rd, 2007

Faker: Quick “Fake Data” Generation in Ruby

I love finding a library that does exactly what it claims to do, and does it in the simplest way possible. Faker by Ben Curtis is a Ruby library, packaged as a Ruby Gem, that generates "fake data" for you, in the form of names, telephone number, e-mail addresses, addresses, and so forth.

For example:

Faker::Name.name  # => "Gwendolyn Wehner"
Faker::Internet.email # => "ava.conn@emmerich.info"
Faker::Internet.free_email # => "angelina.labadie@hotmail.com"
Faker::Internet.user_name # => "mitchel.heaney"

This could be particularly useful for throwing data at any libraries or systems you develop that need to process personal details.

I had trouble installing Faker in the usual way (with gem install faker) as the Ruby Gems server reports that the file could not be found. An easy workaround, for now, is to download the gem manually:

wget http://gems.rubyforge.org/gems/faker-0.2.0.gem
gem install faker

6 Responses to “Faker: Quick “Fake Data” Generation in Ruby”

  1. #1
    Jon Leighton Says:

    Cool. I think the 404 thing is a problem with the Rubyforge server... I had trouble installing Rails today too.

  2. #2
    Daniel Fischer Says:

    This can be particularly useful for test data, sweet. Thanks!

  3. #3
    Tammer Saleh Says:

    Hi Peter,

    I've been having problems with rubyforge all day, so I think the issue is on their side.

  4. #4
    Nikc Says:

    great tool for spammers!

  5. #5
    Koen Van der Auwera Says:

    Nice, thanks!

  6. #6
    Mike Subelsky Says:

    Another alternative is my random_data gem with random dates, times, integers, strings, booleans, addresses, as well as the ability to randomly select from a text file:

    http://random-data.rubyforge.org/