Basic Factory Definition

Learn to write an example for factory_bot.

All the definitions of our factories go inside a call to the method FactoryBot.define, which takes a block argument. Inside that block, we can declare factories to define default data. Each factory declaration takes its own argument in which we can define default values on an attribute-by-attribute basis.

A simple example for the task builder might look like this for tasks:

Get hands-on with 1400+ tech skills courses.