factory_bot
factory_bot copied to clipboard
A library for setting up Ruby objects as test data.
This might be a duplicate of #1639. Giving the context to `initialize_with` would give access to the transient attributes when building the object. This way we can make decisions while...
This comes up all the time. Here's an example from a real test: ```ruby prompts = [ create(:prompt, name: "Prompt 1"), create(:prompt, name: "Prompt 2"), create(:prompt, name: "Prompt 3"), ]...
[Zeal](https://zealdocs.org/) (and also [Dash](https://kapeli.com/dash)) provides a beautiful UI to documentation. The documentation is locally stored, available without an Internet connection. Let's get in on that. The [docset](https://kapeli.com/docsets) guide explains how...
I'd like to be able to clearly, safely, and idiomatically create an object and its many relations. For example: ```ruby new_author = create(:author) distinguished_author = create(:author, with_article_count: 3) assert_equal new_author.articles.count,...
Idea for a lint: complain if two factory definitions create the same object. This is a goal towards these ideals: - each factory definition is the _minimum_ required to make...
The `stub` strategy is specific to ActiveRecord. It exists to create a stub of ActiveRecord model instances. Therefore, it should live in `factory_bot_rails`. My hope is that by doing this...
Fixes https://github.com/thoughtbot/factory_bot/issues/1588 Fixes a bug where a class defined with underscores, ex. `factory :customs_declaration_nl_ddu_1, class: "Customs::Declarations::NL::DDU_1_0"` strips out the underscores and then raises an NameError.
### Description Running code that uses the factory bot gem with Ruby 3.3.0 causes the following warnings to be shown: ``` warning: /opt/hostedtoolcache/Ruby/3.3.1/x64/lib/ruby/3.3.0/observer.rb was loaded from the standard library, but...
New feature useful in the following case ```rb ActiveRecord::Schema.define do create_table :todo_lists do; end create_table :todo_items do |t| t.references :todo_list, null: false t.integer :priority, default: 1, null: false t.index [:todo_list_id,...
Add myself, @sarahraqueld as a new maintainer.