Reputation: 27852
I have a Factory like this:
FactoryGirl.define do
factory :subject do
name 'Calculus'
end
end
And I would like to reference that his parent is 'Maths' which parent is null. How should I do that?
Upvotes: 2
Views: 434
Reputation: 14983
If I understand the question correctly, you can specify a parent as an option to the factory
method:
FactoryGirl.define do
factory :subject do
name 'Subject'
end
factory :maths, :parent => :subject do
name 'Maths'
end
factory :calculus, :parent => :maths do
name 'Calculus'
end
end
This is a fairly contrived example since the child factories override the inherited name
attribute, but does that answer your question?
Upvotes: 1