Factory bot sequence

November 23, 2020

How to sequence a number in Factory Bot

Factory

sequence(:email) { |n| "person#{n}@example.com" }

factory :user do
  name { "Jane Doe" }
  email

  initialize_with { new(name) }
end

Example Used:

create(:user)

Search