factory_bot
factory_bot copied to clipboard
Don't allow duplicate traits
Description
A factory can have the same trait multiple times
Reproduction Steps
FactoryBot.define do
factory :user, class: OpenStruct do
trait :admin do
name { "Admin" }
end
trait :admin do
name { "Administrator" }
end
end
end
Expected behavior
Raises an error when defining the second trait
Actual behavior
Lets me define a second trait but keeps only the first trait
System configuration
factory_bot version: 6.1.0 rails version: 6.1.3.1 ruby version: 2.7.3
Related to https://github.com/thoughtbot/factory_bot/pull/1064#issuecomment-448075022