Factory.define :user do |u|
u.first_name Faker::Name.first_name
u.last_name Faker::Name.last_name
end
However putting curly braces around faker makes it work!
Factory.define :user do |u|
u.first_name { Faker::Name.first_name }
u.last_name { Faker::Name.last_name }
end
10 comments:
save me hours, thanks!
Thankss
Same for me, thanks a lot, I had tried :
Factory.define(:user) do |u|
u.firstname Proc.new { Faker::Name.first_name }
end
But did not return the actuel Proc result.
Thanks so much!
thanks for sharing ...
thanks a lot :D
you're my hero !!!
you're my hero !!!
Thanks! However it's not quite clear to me what makes it work with the curly braces.... any chance someone can explain?
This still behaves the wrong way. how do i fix it? i need to assign the address to a variable to use more than once, but this is causing it to yield the same result each time i run `create(:store)`
factory :store do
fake_city_name = FFaker::Address.city
name { fake_city_name }
code { fake_city_name.upcase[0..2] }
end
Post a Comment