Geeks With Blogs

  • alexmoore Looks like I'm digging a trench this weekend. One of mah favorite things to do. about 678 days ago
  • alexmoore @jpease It kinda looks like a dyson. All it needs is some wheels and a handle. about 679 days ago
  • alexmoore "6 Firewire 2 ports"… Oh god no. about 679 days ago
  • alexmoore Should have been OSX Ocelot. I would have set my hostname to "Babu". about 679 days ago
  • alexmoore Anybody else think it should have been OS X Sea Lion ? about 679 days ago
  • alexmoore Wanted to watch 1984 on Netflix, had to settle for The Hunger Games :'( about 681 days ago
  • alexmoore Playing with LinkedIn Maps over lunch. Not sure what to label these two groups: Green-Ruby-ish vs Blue-.Net-ish? about 682 days ago
  • alexmoore @bladesjester It's that shoulder/neck/back muscle, don't know if I have an ace big enough to wrap all those angles. about 683 days ago
  • alexmoore I wonder if I can ducktape the heating pad to my shoulder so it doesn't fall off... about 683 days ago

Enginerding Alex Moore

One of the first ruby gems I used was the Faker Gem, a nice little ruby gem that ...wait for it... Fakes Data!

Usage is simple; first grab the gem using your gem program:

$sudo gem install faker

Now you can use it in your favorite ruby program or script. For now let's fire up irb and see what we can fake. 

require 'rubygems'
require 'faker'
#Let's see if we can make a fake person...
person_name =
person_email =
person_company =
person_company_slogan =
person_phone = Faker::PhoneNumber.phone_number
person_address = Faker::Address.street_address
person_city =
person_state = Faker::Address.us_state
person_zip = Faker::Address.zip_code
# Wowee-wow-wow. Now let's print him off some business cards
puts "#{person_name}
#{person_city}, #{person_state} #{person_zip}
Call me at : #{person_phone}
Email me at: #{person_email}
It's a pleasure doing business."
# Awesome, now we can go into business and
# get back our money from that Nigerian prince fellow...


As you can see Faker is pretty easy to use; you can build some powerful test bases using it inside a loop:

require 'rubygems'
require 'faker'
require 'activerecord'
1000.times do
  # make a person
  # save person


For more information see the Faker Docs:

In my next post I will show you how you can use all this fake data you're generating to test anything you need data for.


Posted on Monday, January 18, 2010 7:57 PM Ruby | Back to top

Comments on this post: Faker Gem - A Quick and Dirty Introduction

# re: Faker Gem - A Quick and Dirty Introduction
Requesting Gravatar...
Waseem Saddique - Online Marketing, PPC and SEO
Left by Waseem Saddique Brazil on Mar 07, 2011 12:47 PM

Your comment:
 (will show your gravatar)

Copyright © Alex Moore | Powered by: | Join free