FactoryBot.define do factory :meeting do name {"MyString"} desc {"MyText"} parent {nil} intern {false} meetingtyp {nil} # association :calentry, factory: :calentry after(:build) do |c| c.calentry=FactoryBot.build(:calentry, typ: 2) end trait :with_meetingtyp do association :meetingtyp, factory: :meetingtyp end # trait :without_calentry do # calentry nil # end end end