Module: FactoryGirl::Syntax::Sham

Defined in:
lib/factory_girl/syntax/sham.rb

Overview

Adds a Sham module, which provides an alternate interface to FactoryGirl::Sequence.

Usage:

require 'factory_girl/syntax/sham'

Sham.email {|n| "somebody#{n}@example.com" }

FactoryGirl.define do
  factory :user do
    email
  end
end

Note that you can also use Faker, but it is recommended that you simply use a sequence as in the above example, as factory_girl does not provide protection against duplication in randomized sequences, and a randomized value does not provide any tangible benefits over an ascending sequence.

This syntax was derived from Pete Yandell’s machinist.

Defined Under Namespace

Modules: Sham