CheckOps
factory_bot
factory_bot is thoughtbot's MIT-licensed Ruby library for setting up test data with factories, sequences, traits and associations, used with RSpec, Minitest and Rails via factory_bot_rails.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
factory_bot is a fixtures replacement for Ruby with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes and stubbed objects), and support for multiple factories for the same class. Created and maintained by thoughtbot, it was formerly known as factory_girl and inspired similar libraries in other languages, such as factory_boy for Python.
You define factories with default attributes, then override only what a test needs: create(:user, admin: true). Sequences generate unique values, traits bundle named variations (create(:order, :paid)), associations build related records, transient attributes and callbacks customise creation, and build_stubbed creates fast, non-persisted objects. factory_bot_rails integrates with Rails generators and loads factories automatically. Linting (FactoryBot.lint) verifies that all factories build valid objects. Version 6.6.0 was released on 4 May 2026, and the repository had commits in November 2026.
The source code is at thoughtbot/factory_bot on GitHub under the MIT licence, with about 8,200 stars; the most recent commit was on 3 November 2026.
Features
- Concise factories: Defaults defined once, overridden per test.
- Build strategies: create, build, attributes_for and build_stubbed.
- Traits and sequences: Named variations and unique values.
- Rails integration: factory_bot_rails generators and autoloading.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 3 November 2026.
- Community: About 8,200 GitHub stars.
Cons
- Slow tests if overused:
createwith deep associations writes many records. - Hidden coupling: Defaults can obscure what a test depends on.
Usage and Links (Example)
# spec/factories/users.rb
FactoryBot.define do
factory :user do
sequence(:email) { |n| "user#{n}@example.com" }
name { "Ana" }
trait :admin do
admin { true }
end
end
end
# spec/models/user_spec.rb
RSpec.describe User do
it "grants admin access" do
user = build_stubbed(:user, :admin)
expect(user.can_manage?).to be true
end
end
Resources:
Pricing
factory_bot is free and open source under the MIT licence.
Recommended for?
- Rails and Ruby teams replacing YAML fixtures.
- Large test suites needing consistent, readable test data.
Conclusion
factory_bot is the standard Ruby test data library, making tests clearer when used with care around performance.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with factory_bot side by side.
Ffactory_boyfactory_boy is an MIT-licensed test fixtures replacement for Python, inspired by thoughtbot's factory_bot, that builds test objects and ORM records for Django, SQLAlchemy and MongoEngine with Faker integration.Compare with factory_bot
RRSpecRSpec is the MIT-licensed behaviour-driven testing framework for Ruby, made up of rspec-core, rspec-expectations and rspec-mocks, and widely used with Rails via rspec-rails.Compare with factory_bot
MMinitestMinitest is an MIT-licensed, fast and lightweight Ruby testing library providing xUnit-style tests, a spec DSL and benchmarks; it is the default testing framework in Ruby on Rails.Compare with factory_bot
SSimpleCovSimpleCov is an MIT-licensed code coverage analysis tool for Ruby, built on Ruby's Coverage module, with HTML reports, branch coverage, groups, filters and minimum coverage thresholds.Compare with factory_bot- CCapybaraAcceptance test framework for web applications.Compare with factory_bot
WWebMockWebMock is an MIT-licensed Ruby library for stubbing and setting expectations on HTTP requests, supporting many HTTP clients and blocking real network access in tests.Compare with factory_bot