LoginSignup
4

More than 5 years have passed since last update.

FactoryBotで複数個を一括で作る

Last updated at Posted at 2018-12-14
create_list(:user, 10)

create_list に個数を渡すだけ。
神🎉

通常の create 同様、引数も渡せます

create_list(:user, 10, name: 'hoge')

create以外にもbuildも

build_list(:user)

公式ドキュメントが読みやすくて感動
https://devhints.io/factory_bot

FactoryGirlも同様でした
https://www.rubydoc.info/gems/factory_girl/2.2.0/FactoryGirl%2FSyntax%2FMethods:create_list

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4