I have this kind of relation:
class Article < ActiveRecord::Base
class Comment < ActiveRecord::Base
The default scenario inside controllers looks like:
@article = Article.create(:title => “foobar”)
@comment = @article.comments.create(:content => “w00t”)
I had tried to write those factories:
Factory.define :article do |f|
f.title “Hello, world”
Factory.define :comment do |f|
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.
Thanks for any help.