CheckOps home

Tools directory

F

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.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

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

  1. Concise factories: Defaults defined once, overridden per test.
  2. Build strategies: create, build, attributes_for and build_stubbed.
  3. Traits and sequences: Named variations and unique values.
  4. Rails integration: factory_bot_rails generators and autoloading.

Pros

  1. Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 3 November 2026.
  3. Community: About 8,200 GitHub stars.

Cons

  1. Slow tests if overused: create with deep associations writes many records.
  2. Hidden coupling: Defaults can obscure what a test depends on.
# 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.

  1. Rails and Ruby teams replacing YAML fixtures.
  2. 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.