At the moment it's not possible to use unique-feature of faker.
To Reproduce
Factory.define(:company) do |f|
f.id { fake(:alphanumeric, :unique, :alpha, number: 3).upcase } # will fail
f.name { fake(:name, :name) }
end
Expected behavior
id should be unique
Proposal
What do you think about following solution:
We could allow a unique-option at our DSL and if unique is set to true, the method unique is called in front of the specified method (alpha in this case)
Factory.define(:company) do |f|
f.id { fake(:alphanumeric, :alpha, number: 3, unique: true).upcase }
# resulting call will be Faker::Alphanumeric.unique.alpha(number: 3)
end
Describe the bug
At the moment it's not possible to use unique-feature of faker.
To Reproduce
Expected behavior
id should be unique
Proposal
What do you think about following solution: We could allow a
unique
-option at our DSL and ifunique
is set to true, the methodunique
is called in front of the specified method (alpha
in this case)WDYT?
Thanks and best regards