Skip to content
CAI
Software that uses CAICheck a score

thoughtbot/factory_bot_rails

64.4

Adequate · 19 September 2026

376

lines of production code

Ruby

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the Rails integration layer for the FactoryBot library, providing seamless fixture replacement for RSpec, Minitest, and Test::Unit. It automates the generation of factory definitions for models and authentication, while managing file-based fixtures and automatic reloading during development. The gem ensures compatibility across a wide range of Rails versions, from 6.1 to 8.1, by handling framework-specific configurations and initialization.

How it got here

2010 — Rails 8 support and rebranding

7 changes.

The project modernized its test infrastructure by migrating to Aruba and updating the test matrix to include Rails 8.1, while dropping support for older versions. It also completed the rebranding from Factory Girl to Factory Bot, renaming the Rails integration gem and removing legacy railtie code to align with the new naming conventions.

2014–2017 — Generator refactoring and Rails compatibility

6 changes.

This period focused on modernizing the project's generator infrastructure by introducing a modular base class and strategy-based implementations for different test frameworks. Concurrently, the library expanded its compatibility matrix to support Rails versions 5.0 through 8.1 and enhanced developer experience with automated setup scripts and improved factory definition management.

2018–2025 — Rails integration and test coverage

4 changes.

This period focused on establishing robust test infrastructure for Rails integration, including setting up a fake app environment and adding comprehensive tests for factory reloading and file fixtures. It also introduced an authentication generator to simplify the creation of user factories for testing authentication features.

Features

Add FactoryBot generator base class

A new base generator class for FactoryBot has been added to the library, providing shared functionality for generating factory files. This includes logic to determine the source root for templates based on the generator name and a helper method to explicitly specify the class name in the generated factory definition when it differs from the factory name.

lib/generators · high confidence

Add authentication generator for creating user factories

A new AuthenticationGenerator has been added to the FactoryBot library, allowing users to easily generate factory definitions for authentication-related models. This generator creates a 'user' factory template that includes fields for email\_address and password, providing a convenient starting point for testing features that require user authentication.

_lib/generators/factory\bot/authentication · high confidence

Automated local environment setup script

A new \bin/setup\ script has been added to streamline the initial configuration of the development environment. Running this script immediately after cloning the repository automatically installs Ruby dependencies via Bundler, sets up Appraisal for testing against multiple Rails versions, and prepares the necessary directory structure for path management.

bin · high confidence

Factory Bot Rails 6.5.1: File fixture support and configurable definition paths

This release updates the gem to version 6.5.1 and introduces support for \file\_fixture\ in factory definitions, allowing users to reference file-based fixtures directly within their factory syntax. It also adds a new configuration option, \config.factory\_bot.definition\_file\_paths\, enabling users to explicitly specify custom paths for loading factory definitions rather than relying solely on defaults. Additionally, the release includes internal improvements to the file watcher and reloader logic to ensure factory definitions are reloaded correctly during development.

_lib/factory\_bot\rails · high confidence

New model generator for creating factory definitions

Adds a new \ModelGenerator\ that allows users to generate factory definitions for models. The generator supports specifying attributes with types, customizing the output directory and file suffix, and handling both new factory files and appending to existing ones. It also supports namespaced factories and custom filename procedures.

_lib/generators/factory\bot/model · high confidence

Behavioural changes

Migrate Cucumber test infrastructure to Aruba and add Rails 8 support

The test suite now uses the Aruba library for command execution instead of the previous custom Terminal class, which has been removed. This change introduces a configurable timeout (defaulting to 120 seconds) and includes specific optimizations for JRuby environments, such as disabling JIT and adjusting Java options based on architecture. Additionally, the test setup now supports Rails 8 by skipping scenarios that require version 8.0.0 or higher if the current environment does not meet the requirement, and it applies conditional Gemfile modifications and configuration adjustments for Rails versions prior to and at or above 7.1.

features/support · high confidence

Modernized test infrastructure and added Rails 8.1 support

The project has updated its test suite to support Rails 8.1 and added Rails 8.0 to the test matrix, while dropping support for older versions. The build configuration now uses Appraisals to manage dependencies for Rails 6.1 through 8.1, explicitly skipping Spring version 2.1.1 due to known bugs. The Rakefile has been refactored to use Bundler conventions and now runs RSpec, Minitest, Cucumber, and StandardRB by default, replacing the previous Cucumber-only default task.

(repo-wide) · high confidence

Rails integration module renamed from factory\_girl to factory\_bot

The Rails integration entry point has been renamed: the previous \lib/factory\_girl\_rails.rb\ file is removed and replaced by \lib/factory\_bot\_rails.rb\, which loads the railtie and defines the \FactoryBotRails\ module. This reflects the library's rebranding from Factory Girl to Factory Bot and updates the primary Rails integration file accordingly.

lib · high confidence

Refactored generator logic into dedicated strategy classes

The generator implementation in lib/factory\_bot\_rails/generators has been restructured to use specific strategy classes for different test environments. A new NonRSpecGenerator handles setup for non-RSpec frameworks by configuring the test framework with factory\_bot as the fixture replacement, while the RSpecGenerator explicitly manages the fixture replacement setting and directory configuration for RSpec projects. A NullGenerator is also introduced to provide a no-op implementation, likely for cases where no specific generator logic is required. This change isolates the logic for different test frameworks, making the generation process more modular and maintainable.

_lib/factory\_bot\rails/generators · high confidence

Removal of legacy Factory Girl Railtie

The \lib/factory\_girl\_rails/railtie.rb\ file has been deleted, removing the automatic configuration that previously set \Factory.definition\_file\_paths\ to \test/factories\ and \spec/factories\ and triggered \Factory.find\_definitions\ on Rails initialization. This change eliminates the legacy Railtie integration, aligning with the broader migration from the \Factory\ class to the \FactoryGirl\ module and requiring users to rely on updated initialization mechanisms or explicit configuration for factory loading.

_lib/factory\_girl\rails · high confidence

Updated step definitions for Rails application generation and configuration

The step definitions in features/step\_definitions have been refactored to support modern Rails application scaffolding and configuration. The 'I create a new rails application' step now generates apps with specific flags (such as --api, --skip-bootsnap, and --skip-bundle) and applies a custom template, replacing the previous generic generation method. New steps allow users to add local or external gem dependencies, configure factory bot settings (including custom directories), and comment out gems from the Gemfile. Additionally, new steps for running commands with clean environments or Spring enabled have been added to support testing with Spring.

_features/step\definitions · high confidence

Test coverage

Added test infrastructure for Rails integration; Added tests for factory reloading and file fixtures; Added tests for file\_fixture support in Factory definitions; Factory Bot Rails integration and generator behavior.

Dependencies

Expanded Appraisal matrix to support Rails 5.0 through 8.1

The gemfiles directory now includes dedicated Appraisal configurations for Rails versions 5.0, 5.1, 5.2, 6.0, 6.1, 7.0, 7.1, 7.2, 8.0, and 8.1. This allows the library to be tested against a comprehensive range of Rails versions, ensuring compatibility across major releases. Each gemfile specifies the appropriate Rails version and associated dependencies (such as puma, sqlite3, and listen) required for that specific Rails release, enabling developers to verify their code works correctly with their chosen Rails version.

gemfiles · high confidence

Upgrade to factory\_bot\_rails 6.5.1 with Rails 8.0 support

The gem has been updated to version 6.5.1, renaming the package from factory\_girl\_rails to factory\_bot\_rails to reflect the underlying library's name change. This release upgrades the runtime dependency on factory\_bot to version 6.5 and requires Rails 6.1 or newer, with the current lockfile resolving against Rails 8.0.3. Additionally, the minimum supported Ruby version has been raised to 3.1.0.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 64.

Lenses

  • Code Health 100
  • Architecture 69
  • Maturity 57
  • Readiness 66
  • Security 72

Changes since last survey

  • 300 commits — 280 feature/other, 20 fixes

By area

  • (root) — 240 commits
  • features/fixture_replacement_config.feature — 10 commits
  • lib/factory_bot_rails — 8 commits
  • features/generators.feature — 7 commits
  • lib/generators — 6 commits
  • .github/workflows — 5 commits
  • features/load_definitions.feature — 4 commits
  • features/reloading.feature — 4 commits
  • features/step_definitions — 4 commits
  • lib/factory_girl_rails — 3 commits
  • .github/dependabot.yml — 2 commits
  • features/support — 2 commits
  • (repo) — 1 commit
  • .github/ISSUE_TEMPLATE — 1 commit
  • lib/rails — 1 commit
  • spec/factory_bot_rails — 1 commit
  • spec/support — 1 commit

Notable commits

  • fix: Bundle in an attempt to fix travis
  • fix: Fix Cucumber tests (#536)
  • fix: Fix README
  • fix: Fix a link to old files (#428)
  • fix: Fix bug when configuring FactoryGirl and RSpec fixture dir
  • fix: Fix definition_file_paths setting for Rails engine
  • fix: Fix development dependencies (#526)
  • fix: Fix filename in gemspec
  • fix: Fix for factory class naming (#366)
  • fix: Fix hash syntax error (#553)
  • fix: Fix incorrect escaping [ci skip]
  • fix: Fix remaining RuboCop TODOs
  • fix: Fix standardrb violations (#482)
  • fix: Fix style link in CONTRIBUTING.md [ci skip] (#402)
  • fix: Fix syntax error in documentation for filename_proc option
  • fix: Fix undefined method config (#440)
  • fix: Fix when use fixture_replacement with suffix option.
  • fix: Revert "Test travis config"
  • fix: Update Gemfile.lock to upgrade dependencies and fix version inconsistencies (#545)
  • fix: fix indent of generated factory file
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

thoughtbot/factory_bot_rails was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 20e3696ebc1e17164f22d0aac0537e3930acf0c4 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.