thoughtbot / thoughtbot/factory_bot

attributes_for does not use initialize_with like the docs states it does

Open
#1,606 2 comments 0 reactions 1 assignee View on GitHub

@mike-burns is already working on this.

Since Dec 27, 2023.

bug
Dominant language
Ruby
Stars
8.2k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Description

According to the docs, attributes_for constructs a hash using initialize_with, but this isn't actually the case.

Is this a bug, or incorrect documentation?

Reproduction Steps

Reproduction script: https://gist.github.com/ezekg/7738249c671e48c0372884c847e2559f

Expected behavior

The initialize_with callback is used during creation of the attributes_for hash.

Actual behavior

The initialize_with callback is not used for the attributes_for hash.

System configuration

factory_bot version: v6.4.2
rails version: v7.1.2
ruby version: v3.2.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.