OSS TanbouSign in with GitHub

Integrate Factory Bot with Rails through automatic factory loading, generators, and file fixtures

About these scores

OSS scale score is an unbounded metric that log-compresses and weights Stars, Watchers, Forks, and Contributors. Discovery score is the current OSS scale score minus the score at discovery. Update pace is commits in the last 30 days, growth momentum is the OSS scale score difference within the recent observation window, and OSS health is a 0–100 rating based on available recency, Community Health, and release data.

Stars
3,139
Primary language
Ruby
License
MIT
Repository last updated
Jul 21, 2026
On this page

Overview

factory_bot_rails integrates Factory Bot with Rails. It automatically loads factory definitions from Rails project conventions, replaces generated fixtures with factories, and makes Rails file fixtures available inside factory definitions. The current version is 6.5.1.

Features and best fit

Based on official documentation; not hands-on tested · Content checked:

Key features

Automatically load factory definitions from conventional Rails paths

Definitions in factories.rb, test/factories, spec/factories, and related paths are loaded automatically. config.factory_bot.definition_file_paths can point to custom locations or disable automatic loading.

Sources: [2]

Connect Rails generators and file fixtures to Factory Bot workflows

When installed in the development group, Rails model generation can create factories instead of fixtures, with configurable directories, suffixes, and templates. Factory blocks can also use ActiveSupport file_fixture helpers.

Sources: [2][4]

Best fit

Fits Rails test suites that use Factory Bot as their standard fixture replacement

It is useful for RSpec or Minitest suites that want Factory Bot definitions, generator behavior, reloading, and fixture paths integrated with the Rails lifecycle. The core factory_bot gem remains the underlying test-data library.

Sources: [2]

Before adoption

Version 6.5.1 requires Ruby 3.1+, Rails 6.1+, and Factory Bot 6.5.x

The gemspec requires Ruby 3.1 or newer, railties 6.1 or newer, and factory_bot ~> 6.5. Large factory graphs can hide test assumptions and create unnecessary database rows, so prefer non-persistent build strategies unless persistence is part of the behavior under test.

Sources: [3][4][2]

Official sources

  1. [1]thoughtbot/factory_bot_rails — GitHub repository(2026-10-06)
  2. [2]factory_bot_rails — README(2026-10-06)
  3. [3]factory_bot_rails — gemspec(2026-10-06)
  4. [4]factory_bot_rails — NEWS(2026-10-06)
  5. [5]factory_bot_rails — v6.5.1 release(2026-10-06)
Supplemental curator note

This is a separate repository from core factory_bot and handles Rails-specific loading, generators, and fixture integration. Use build or build_stubbed when database persistence is not part of the test and keep factory graphs small enough to preserve clear test assumptions.

Try it in 3 steps

  1. 1

    Get the source

    git clone --depth 1 https://github.com/thoughtbot/factory_bot_rails.git
  2. 2

    Enter the repository

    cd factory_bot_rails
  3. 3

    Check the official steps

    Continue with the commands in the README Installation, Quick Start, or Getting Started section.

    find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
Check the official README

Growth

Growth trends · Last 30 days

3,139 Stars

Trend data is still being collected.

Development activity

Last 90 days · weekly

Commits (last 30 days)
0
Open PRs
5

Development activity is still being collected.

Built with

Categories and tags

GitHub data

GitHub dataView detailed GitHub data
Stars
3,139
Forks
376
Watchers
58
Open issues
3
Contributors
77
Owner type
Organization
Primary language
Ruby
License
MIT
Repository last updated
Jul 21, 2026
Write a related article

Share a guide or use case for this OSS in Markdown. Articles are published after administrator approval.

Report incorrect information

Tell us if any listing information is incorrect or outdated.

After reading this page, do you know what to do next?