paulelliott/fabrication — Issue #81: Generating different data
Author: cmoel
Created: 2012-01-13 02:17:43+00:00
State: open

I don't know if this is more because I'm new to Fabricator or because of a setting or what...

In my users_spec request spec, I have: `@user = Fabricate.build(:user)`. My tests fail when, from everything I know, they should be passing (I say that because it works using FactoryGirl).

This is my user_fabricator.rb:

Fabricator :user do

first_name Faker::Name.first_name
last_name Faker::Name.last_name
email { sequence(:email) {|n| "user#{n}@example.com" } }
password "foobar"
password_confirmation "foobar"

# A user has_many events
events(count: (3)) { |user, i| Fabricate(:event, user: user) }
end

In the rails console, I run `@user = Fabricate.build(:user)` and generate a User. I run it again and it generates a User with the same `:first_name` and `:last_name`. (The `:email` changes because it is a sequence). I would prefer to use Faker for the email address as well, but can't figure out how to do it. Is there a way I can force it to use different attributes?