J'utilise l'exemple FactoryGirl pour les relations has_many
de http://robots.thoughtbot.com/post/254496652/aint-no-calla-back-girl. Plus précisément, l'exemple est:FactoryGirl has_many association
Modèles:
class Article < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :article
end
usines:
factory :article do
body 'password'
factory :article_with_comment do
after_create do |article|
create(:comment, article: article)
end
end
end
factory :comment do
body 'Great article!'
end
Quand je lance ce même exemple (avec le schéma approprié, bien sûr), une erreur est renvoyée
Y at-il une nouvelle façon de créer des modèles avechas_many
associations avec FactoryGirl?
2.0.0p195 :001 > require "factory_girl_rails"
=> true
2.0.0p195 :002 > article = FactoryGirl.create(:article_with_comment)
ArgumentError: wrong number of arguments (3 for 1..2)