タイトルの通り,RSpec でポリモーフィック関連のモデルを FactoryGirl で生成してみた.
特にハマるところはなくて,Stack Overflow に載ってた書き方ですんなり書けた.関連まで意識した FactoryGirl になって個人的にスッキリ!
ruby on rails - FactoryGirl and polymorphic associations - Stack Overflow
FactoryGirl.define do factory :musical_user, class: "User" do association :profile, factory: :musician #attributes for user end factory :musician do #attributes for musician end end