Post

factory botでユニークな値を設定

sequence(:username) { |n| "user#{n}" }

FactoryBot.define do factory :user do first_name 'John' last_name 'Doe' birthdate { 21.years.ago } admin false sequence(:username) { |n| "user#{n}" } end end

Factory Bot cheatsheet

This post is licensed under CC BY 4.0 by the author.