factory_bot icon indicating copy to clipboard operation
factory_bot copied to clipboard

A library for setting up Ruby objects as test data.

Results 135 factory_bot issues
Sort by recently updated
recently updated
newest added

If we want to specify traits in implicit associations, we have to use `:factory` option. This is not only a naming problem, but also redundant in implicit style, because when...

Fixes https://github.com/thoughtbot/factory_bot/issues/1633 add support for `before(:build)` callback as requested in the issue Tested the changes by adding the local gem to a project ![image](https://github.com/thoughtbot/factory_bot/assets/135416851/11f97496-7a16-4dff-870d-cbc0d3a7392d) ![image](https://github.com/thoughtbot/factory_bot/assets/135416851/f3c36edb-c411-4687-9a82-87e75bb01881) I am honestly not sure...

### Problem this feature will solve I want to disable our `Bullet` gem when FactoryBot is building instances and creating records, because I don't care about n+1 problems inside my...

feature

### Description When i try to upgrade to Rails 7.1 from Rails 6.0, i get some errors in my specs, i found for some reason when i use build_stubbed in...

bug

Following readme results in the code below rails_helper.rb: ```ruby # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require_relative '../config/environment' #...

documentation

### Problem this feature will solve Several of our tests rely on `sequence`s being reset between examples. So we call `FactoryBot.reload` in a `before(:each)`. But this interferes with us being...

feature

I struggled to figure out how to make the has_many association work with the build strategy in a simple way. I asked ChatGPT and it came up with this strategy,...

documentation

The current implementation seems to load all definition files that match the following pattern in this order: 1. `factories.rb` 1. `factories/**/*.rb` 1. `test/factories.rb` 1. `test/factories/**/*.rb` 1. `spec/factories.rb` 1. `spec/factories/**/*.rb` https://github.com/thoughtbot/factory_bot/blob/053ef4af1a7fd845bb8f5f9ae65967249c247617/lib/factory_bot/find_definitions.rb#L10-L24...

documentation

Fixes https://github.com/thoughtbot/factory_bot/issues/1647 Allow creation of sequence attributes in `create_list` This PR is more of a proof of concept, if I get the green light I can add documentation and more...

The `context`, as passed to the various hooks, does not tell us whether a key was overridden by the user when building/creating/stubbing the object. This means we can't know whether...

feature