Improve factories for external contributors
Recent discussion we had about where to put factories code:
@brodock :
how should factories be organized? we have both
spec/factories/*.rb
andspec/factories.rb
(edited)
@gabriel: I know! It drives me crazy. Originally we only had
spec/factories.rb
, but I think the model generator creates a separate one for each model, so we ended up with a few of those.
spec/factories/project.rb
is probably big enough that it warrants its own file, so I was thinking we should just go all-in and have one file for each model class
It's been on my todo list for a while
😦
The important thing is that we be consistent, so you're not stuck going "is this factory I want to edit in factories.rb or its own file?"
Some of the spec/factories/model_name.rb
got there by the use of related generators (rspec:models
for example).
@sytses proposes that if we don't want new factories to go to spec/factories.rb
we should add a notice there to explain where new code should go.
If we want to keep single files the exception, but still allow the creation of them, I believe a README.md
in spec/factories
could give some additional instructions when to use one or the other.