私の意見と私の目的のために、factory_girl
完全に最悪です。いくつかの制限は次のとおりです。
デバッグのサポートなし
ステートメントを含めるdebugger
と、それらはモデル属性として扱われます。デバッガーを呼び出す代わりに、奇妙なエラーが発生します。
FactoryGirl.define do
factory :admin do
name do
debugger # <-- Does not work.
Forgery(:name).full_name
end
email { Forgery(:email).address }
debugger # <-- Does not work either.
password "secret"
end
end
関連付けの制限
私は愚かすぎるのでしょうか、それともユーザーに 2 つの投稿を追加するエレガントな方法はありませんか?
FactoryGirl.define do
factory :post do
title "Foobar"
content "Some content"
end
factory :user do
name { Forgery(:name).full_name }
email { Forgery(:email).address }
# This does not work, if the Post model requires Post#user to be set.
posts [FactoryGirl.create(:post), FactoryGirl.create(:post)]
end
end
Factory Girlも参照してください- レコードが継続的に作成されるのはなぜですか?
レールで奇妙なバグを引き起こす傾向があります
何が起こったのか覚えていませんが、factory_girl で奇妙な問題が発生することがよくあります。
したがって、これらの例を考えてみましょう。これらの問題がない factory_girl の代替手段はありますか?