I've often heard not to use random data when writing tests, which seems reasonable for most data.
However, I can't think of any reason why a random ID for records would be bad?
For example:
FactoryGirl.define do
factory :dog do
id { rand(100_000) }
name "Sparky"
legs 4
end
end
end
As long as I make sure any associated records use the correct, randomly-assigned ID, I don't see how this could be an issue.
Aucun commentaire:
Enregistrer un commentaire