Factory Bot (Rails Testing)

The class of the test object is either determined through the name of the factory or set explicitly.

[4] Factory Bot allows creating unique values for a test attribute in a given format.

This allows the user to reuse common attributes from parent factories and avoid writing duplicate code for duplicate attributes.

Factories can be written in a nested fashion to leverage inheritance.

Factory Bot allows custom code to be injected at four different stages:[4]