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. factory_bot provides a framework and DSL for defining and using factories - less error-prone, more explicit, and all-around easier to work with than fixtures. Each factory has a name and a set of attributes. The name is used to guess the class of the object by default. It is recommended that you have one factory for each class that provides the simplest set of attributes necessary to create an instance of that class. If you're creating ActiveRecord objects, that means that you should only provide attributes that are required through validations and that do not have defaults. Other factories can be created through inheritance to cover common scenarios for each class.

Features

  • Build or create multiple records
  • Custom methods to persist objects
  • ActiveSupport instrumentation
  • Rails preloaders and RSpec
  • Use without a bundler
  • Modify factories

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow factory_bot

factory_bot Web Site

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of factory_bot!

Additional Project Details

Programming Language

Ruby

Related Categories

Ruby Software Testing Tool, Ruby Libraries

Registered

2021-07-30