Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ad hoc sequences in create_list #1647

Open
mike-burns opened this issue May 10, 2024 · 0 comments · May be fixed by #1650
Open

Ad hoc sequences in create_list #1647

mike-burns opened this issue May 10, 2024 · 0 comments · May be fixed by #1650
Labels

Comments

@mike-burns
Copy link
Contributor

This comes up all the time. Here's an example from a real test:

prompts = [
  create(:prompt, name: "Prompt 1"),
  create(:prompt, name: "Prompt 2"),
  create(:prompt, name: "Prompt 3"),
]

I'd love to be able to write something else. Here's an example, maybe:

prompts = FactoryBot.create_list(
            :prompt,
            3,
            name: FactoryBot.build_sequence { |n| "Prompt #{n}" },
          )

Note that create_list already takes a block:

This block takes the produced object and the zero-based index as arguments, and returns an updated object.

But we want to get in there before it produces the object.

@mohammednasser-32 mohammednasser-32 linked a pull request May 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant