Skip to content

FactoryBot cheatsheet

Jim Coble edited this page Feb 26, 2019 · 4 revisions

Using FactoryBot definitions in dummy app rails console in an Engine

FactoryBot.definition_file_paths = %w(../factories)
FactoryBot.find_definitions

When running rails console in project directory using bundle exec rails c

FactoryBot.definition_file_paths = %w(spec/factories)
FactoryBot.find_definitions

This enables you to use FactoryBot factories in the rails console; e.g.,

ddrfile = FactoryBot.build(:ddr_file)