I'm trying to populate some fake data into a factory using the Faker gem:
Factory.define :user do |user|
user.first_name Faker::Name::first_name
user.last_name Faker::Name::last_name
user.sequence(:email) {|n| "user#{n}@blow.com" }
end
However while I expect this to produce users who have different first_name and last_names, each one is the same:
>> Factory(:user)
=> #<User id: 16, email: "user7@blow.com", created_at: "2011-03-18 18:29:33",
updated_at: "2011-03-18 18:29:33", first_name: "Bailey", last_name: "Durgan">
>> Factory(:user)
=> #<User id: 17, email: "user8@blow.com", created_at: "2011-03-18 18:29:39",
updated_at: "2011-03-18 18:29:39", first_name: "Bailey", last_name: "Durgan">
How can I get the Faker gem to generate new names for each users and not just reuse the original ones?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…