Practical Web Programming

Wednesday, October 23, 2013

Use Factory_Girl to Create Mock Data

Step by step guide"

1) Edit the Gemfile
    group :test do
        .
        .
        .
        gem 'factory_girl_rails', '4.1.0'
    end

2) Install it
    $ bundle install

3) Factory Girl format for Person model
    FactoryGirl.define do
      factory :person do
        name     "Michael Hartl"
        email    "michael@example.com"
        password "foobar"
        password_confirmation "foobar"
      end
    end

0 comments:

Recent Post