I'm setting up an Artist model that has nameand birth_name attributes. In some cases, an artist's stage name is synonomous with their real name, vice-versa. What I'd like to do in my factory is use the birth_name (created using Faker) as the name attribute. I tried simply referencing as so:
FactoryGirl.define do
factory :artist do
name { birth_name }
birth_name { Faker::Name.name }
end
end
but get this error:
ArgumentError: Factory not registered: birth_name
What's the best way to get this to work?
FactoryBot.define do
factory :artist do
birth_name { Faker::Name.name }
name { birth_name }
end
end
Reference:
FactoryBot - Dependent Attributes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With