Factory bot traits

November 21, 2020

How to use traits in Factory Bot

Factory

FactoryBot.define do
  factory :example do
    slug 'original'

    trait :other do
      slug 'other'
    end
  end
end

Example Used:

create(:example, :other)

Search