# thoughtbot/factory_bot_rails

Factory Bot ♥ Rails

Repository: https://github.com/thoughtbot/factory_bot_rails
Canonical: https://ross.abutalabs.com/products/factory_bot_rails
Homepage: https://thoughtbot.com/services/ruby-on-rails
Language: Ruby
License: MIT
License Family: permissive
Last push: 2026-07-21T12:19:09+00:00

## Health v2 (maintenance only)
Score: 70/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 93, release rhythm 22, longevity 100
- inputs: {"age_days": 5945, "days_push": 43, "days_rel": 362, "gap_med": 157.5, "n_releases_24m": 3}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 3137, forks 376 (observed 2026-08-28T04:07:45.733743+00:00)

## What it is
factory_bot_rails provides Rails integration for Factory Bot, a fixtures replacement library for defining test data with a straightforward factory definition syntax. It supports multiple build strategies (saved instances, unsaved instances, attribute hashes, stubbed objects), factory inheritance, automatic factory definition loading, and Rails generators that produce factories instead of fixtures.

## Use cases
- replace Rails fixtures with factories in my test suite
- generate test data for Rails models
- create saved and unsaved instances for RSpec tests
- define multiple factories for the same class like user and admin_user
- auto-load factory definitions from spec/factories
- generate factories instead of fixtures with Rails generators

## When to choose
- you are building a Rails app and need maintainable, flexible test data setup
- you want fixtures replacement with build strategies and factory inheritance
- you use RSpec, Minitest, or Test::Unit and want automatic factory loading and generator integration

## When to avoid
- you are not using Ruby on Rails (use the plain factory_bot gem instead)
- you prefer simple built-in Rails fixtures or a different test data approach
- your project does not have a test suite that needs object factories

## Facets
- artifact type: library
- maturity: stable
- function: testing, mocking, data-generation
- domain: testing, web-development, developer-tools
- platform: ruby
- tags: fixtures-replacement, test-data, factories, ruby-gem, rails-integration, rails

## Member repositories
- thoughtbot/factory_bot_rails (main) score 70

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:07:45.733743+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-29T18:45:36.608240+00:00, confidence not recorded.
  - readme: https://github.com/thoughtbot/factory_bot_rails (fetched 2026-08-28T04:07:45.733743+00:00, sha 0b4c4e9c40a5)
  - homepage: https://thoughtbot.com/services/ruby-on-rails (fetched 2026-08-29T09:40:48.467495+00:00, sha a485bc4ffcea)
- Data as of 2026-08-30T08:39:29.467469+00:00.
