🖥
#ruby #rails の #FactoryBot で association を使わずに無理やり BuildStrategy ( cre
Example of forcing condition inversion of BuildStrategy (create / build / attributes_for) forcibly without using association in #FactoryBot of #ruby #rails
FactoryBot.define do
factory :company do
user do
build_stragy = self.instance_variable_get(:@build_strategy).class
if build_stragy == FactoryBot::Strategy::Create
create :user
else
build :user
end
end
end
end
Original by Github issue
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。
公開日時
2019-07-28
Discussion