Factory.define :article do |f|
f.title "Hello, world"
end
Factory.define :comment do |f|
f.content "Awesome!"
f.association :article
end
But my syntax is not correct about the association. It's a little bit
tricky because of the comment's article_id protected attribute. So I
think this should be better if I declare the association inside the
article factory, but I don't see how to process.
It's also a bit confusing because your naming your factories the same
as the property name. It might be more clear if you set them with more
'real' names like
Factory.define :hello_world_article, :class => Article do |f|
f.title "Hello, world"
end
Factory.define :awesome_comment, :class => Comment do |f|
f.content "Awesome!"
f.association :article, :factory => :hello_world_article
end