FactoryBot: create the same object multiple times

Solution 1:

You can create a list like this (hence create x objects at once):

FactoryBot.create_list(:model_1, 3)

Documentation lives here.

Note: FactoryBot was originally named FactoryGirl

Solution 2:

FactoryBot.create_list :factory_name, 2, attribute_name: 'value'

Simple and best way to move.

You can ignore the attribute names if not needed the same, and use sequence instead.

Solution 3:

Not sure if this has been updated since the answer was posted, but now you would do the following

FactoryBot.create_list(:model_1, 3)

see Getting Started