Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

factory_bot

> 后端框架
Open source

A library for setting up Ruby objects as test data.

8.2K stars0 likes1 views
WebsiteGitHub

About

A library for setting up Ruby objects as test data.

factory_bot

Build Status Gem Version

factory_bot is a fixtures replacement 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 (user, admin_user, and so on), including factory inheritance.

If you want to use factory_bot with Rails, see factory_bot_rails.

Interested in the history of the project name? You can find the history here

Transitioning from factory_girl? Check out the upgrade guide.

Documentation

See our extensive reference, guides, and cookbook in the factory_bot book.

For information on integrations with third party libraries, such as RSpec or Rails, see the factory_bot wiki.

We also have a detailed introductory video, available for free on Upcase.

Install

Run:

ruby
bundle add factory_bot

To install the gem manually from your shell, run:

bash
gem install factory_bot

Supported Ruby versions

Supported Ruby versions are listed in .github/workflows/build.yml (source)

More Information

  • Rubygems
  • Stack Overflow
  • Issues
  • GIANT ROBOTS SMASHING INTO OTHER GIANT ROBOTS

Useful Tools

  • FactoryTrace - helps to find unused factories and traits.
  • ruby-lsp-factory_bot / ruby-lsp-rails-factory-bot - integration with ruby-lsp to provide intellisense

Contributing

Please see CONTRIBUTING.md.

factory_bot was originally written by Joe Ferris and is maintained by thoughtbot. Many improvements and bugfixes were contributed by the open source community.

License

factory_bot is Copyright © 2008 Joe Ferris and thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects. We are available for hire.

Issues· 83 open

View all issuesOpen on GitHub
  • #1679

    Fix shape variations with attribute assigner

    bugUpdated Sep 16, 2026
  • #1835

    Move the factory_girl upgrade guide link out of the README

    featureUpdated Aug 30, 2026
  • #1825

    Refactor internal references to ignored (attributes) to transient attributes

    good first issueUpdated Aug 24, 2026
  • #1826

    Feedback on Documentation

    documentationgood first issuehelp wantedUpdated Jul 31, 2026
  • #1827

    Meta Issue on Issues

    Updated Jul 15, 2026
  • #1787

    create_list does not correctly override parameter

    bugUpdated Jun 3, 2026
  • #1743

    FactoryBot.modify does not override gem factory

    bugUpdated Jun 3, 2026
  • #1788

    insert_all or active_record-import integration

    featureUpdated Jun 3, 2026
  • #1681

    Add find_or_create_by Method

    featureUpdated Mar 12, 2026
  • #1702

    Question: Option to disable broadcasts when creating objects via factory_bot

    featureUpdated Oct 27, 2025

> Tags

Rubyfactoriesfactory-botfactory-girlfixtures

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedOct 1, 2026
Category后端框架
PricingOpen source

> Related tools

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架