create_list does not correctly override parameter
Author: GMoliniCreated Oct 24, 2025Updated Jun 3, 2026
Labelsbug
Description
Ive got a factory bot definition like this
FactoryBot.define do
factory :emails_message, class: 'Emails::Message' do
subject { Faker::Lorem.sentence }
thread_subject { Faker::Lorem.sentence }
from { Faker::Internet.unique.email }
from_display_name { "#{Faker::Name.name} <#{from}>" }
end
endIf I create a list like this:
email_address = "[email protected]"
emails = create_list(:emails_message, 10, from: email_address)Its very weird because it uses the correct from in the from_display_name, but is incorrectly saved in the from attribute
If I print the emails: p emails.map { |r| [r.from, r.from_display_name] }
[["[email protected]", "Prof. Trudi Langosh <[email protected]>"], ["[email protected]", "Courtney Becker <[email protected]>"], ["[email protected]", "Ollie Steuber <[email protected]>"], ["[email protected]", "Johnathan Marvin <[email protected]>"], ["[email protected]", "Jacinto O'Reilly <[email protected]>"], ["[email protected]", "Mrs. Thanh Schinner <[email protected]>"], ["[email protected]", "Stevie Larson <[email protected]>"], ["[email protected]", "Alena Abbott MD <[email protected]>"], ["[email protected]", "Lavona Becker Ret. <[email protected]>"], ["[email protected]", "Msgr. Vada Rolfson <[email protected]>"]]System configuration
factory_bot version: 6.2.1 rails version: 7.0.8 ruby version: 3.2.2
Edit: Ive updated factory_bot to version 6.5.5 and factory_bot_rails to 6.5.1 and it still happens
Source: thoughtbot/factory_bot