FactoryBot.find_definitions
The FactoryBot.find_definitions
method loads in all factory_bot definitions
across the project.
The load order is controlled by the FactoryBot.definition_file_paths
attribute. The default load order is:
factories.rb
test/factories.rb
test/factories/**/*.rb
spec/factories.rb
spec/factories/**/*.rb
Rails
The .find_definitions
method is called automatically by factory_bot_rails
after initialize. The .definition_file_paths
can be set during initialization
(e.g. config/initializers
), or via
Rails.application.config.factory_bot.definition_file_paths
.