フォルダーの作成
「spec」フォルダー内に「factories」フォルダーを作成
ファイルの作成
「factories」内に「モデル名(複数形).rb」ファイルを作成。
例えば、
「spec/factories/users.rb」
ファイルに以下記載
以下、例
spec/factories/users.rb
FactoryBot.define do
factory :user do
name {Faker::Name.last_name}
email {Faker::Internet.free_email}
password {Faker::Internet.password(min_length: 6)}
password_confirmation {password}
end
end
データ型の選び方
公式ページを参照
https://github.com/faker-ruby/faker
#techcamp136期