# thoughtbot/factory_bot

A library for setting up Ruby objects as test data.

Repository: https://github.com/thoughtbot/factory_bot
Canonical: https://ross.abutalabs.com/products/factory_bot
Homepage: https://thoughtbot.com
Language: Ruby
License: MIT
License Family: permissive
Topics: factory-girl, ruby, thoughtbot, rubygems, testing, fixtures, factories, rails, factory-bot
Last push: 2026-08-21T15:39:33+00:00

## Health v2 (maintenance only)
Score: 89/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 98, release rhythm 70, longevity 100
- inputs: {"age_days": 6665, "days_push": 12, "days_rel": 121, "gap_med": 70, "n_releases_24m": 8}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 8169, forks 2552 (observed 2026-08-28T04:10:14.018019+00:00)

## What it is
factory_bot is a Ruby library for defining and building test data objects with a straightforward factory definition syntax. It supports multiple build strategies (saved instances, unsaved instances, attribute hashes, stubbed objects), multiple factories per class, and factory inheritance, serving as a fixtures replacement.

## Use cases
- generate test data for ruby tests
- replace rails fixtures with factories
- create test objects with associations in rspec
- define reusable factories with traits and inheritance
- set up test records for rails integration tests
- stub objects in unit tests without hitting the database

## When to choose
- you write Ruby or Rails tests and need flexible, maintainable test data setup
- you want a fixtures replacement with build strategies like stubs and unsaved instances
- you need factory inheritance, traits, and multiple factories per class
- you use RSpec, Minitest, or Rails test suites

## When to avoid
- you are not working in Ruby or a Ruby-based framework
- you prefer plain fixtures, seeds, or hand-rolled test data builders
- you need test data generation for non-Ruby languages

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

## Member repositories
- thoughtbot/factory_bot (main) score 89

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:10:14.018019+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-29T17:29:35.794435+00:00, confidence not recorded.
  - readme: https://github.com/thoughtbot/factory_bot (fetched 2026-08-28T04:10:14.018019+00:00, sha 5e993b34586c)
  - homepage: https://thoughtbot.com (fetched 2026-08-29T08:28:25.051237+00:00, sha 5510254df796)
  - site_page: https://thoughtbot.com/case-studies/closeknit-health (fetched 2026-08-29T08:28:25.060520+00:00, sha ec773542ed58)
  - site_page: https://thoughtbot.com/services (fetched 2026-08-29T08:28:25.062409+00:00, sha 5b152b8c27da)
  - site_page: https://thoughtbot.com/our-company (fetched 2026-08-29T08:28:25.064267+00:00, sha 9e2e18b981fb)
- Data as of 2026-08-30T08:39:29.467469+00:00.
