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.
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.
Official sources
- [1]thoughtbot/factory_bot_rails — GitHub repository(2026-10-06)
- [2]factory_bot_rails — README(2026-10-06)
- [3]factory_bot_rails — gemspec(2026-10-06)
- [4]factory_bot_rails — NEWS(2026-10-06)
- [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
Get the source
git clone --depth 1 https://github.com/thoughtbot/factory_bot_rails.git - 2
Enter the repository
cd factory_bot_rails - 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
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
Categories
GitHub data
GitHub dataView detailed GitHub data
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Rswag2,202 Stars
2 shared tag(s) · 1 shared category(s) · Same language
test Rails APIs through request specs and generate OpenAPI documents and Swagger UI from the same definitions
Ruby - The Composable Architecture14,952 Stars
1 shared tag(s) · 3 shared category(s)
build composable SwiftUI and UIKit features around State, Action, Reducer, and Store
Swift - CarrierWave8,768 Stars
1 shared tag(s) · 2 shared category(s) · Same language
Handle Ruby web-app file uploads with cache/store separation, processing, and ORM-mounted uploaders
Ruby - Kaminari8,667 Stars
1 shared tag(s) · 2 shared category(s) · Same language
Add pagination to Ruby web apps with chainable scopes and rendering helpers
Ruby - PaperTrail7,030 Stars
1 shared tag(s) · 2 shared category(s) · Same language
Store ActiveRecord model changes as version records for auditing, reification, and history
Ruby - Hanami6,422 Stars
1 shared tag(s) · 2 shared category(s) · Same language
Compose maintainable Ruby applications from focused router, action, view, database, and asset components
Ruby
Report incorrect information
Tell us if any listing information is incorrect or outdated.