-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove guideline about using one factories.rb file per project #685
Remove guideline about using one factories.rb file per project #685
Conversation
6adef16
to
464e479
Compare
I feel like my opinion on this changes once it gets to a certain size. When it's easy to skim up and down, one file is really helpful. But once it gets over a certain size, it's more difficult to get a feeling of the factories when scanning it. The prior rule of keeping them alphabetically sorted helps this a lot, but is not, in my experience, followed. How do people feel that we should split the file? By model? Or something else? |
I think that this is inevitable for most projects. I guess if you know your project will remain very small, keeping all of the factories in one file could make things more readable, but I've encountered very few projects like that.
I think generally one factory per file is good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like one file / factory. The only annoying thing one searching for files in my editor (CMD + P), they always show up along side models. I wonder if they were called spec/factories/<model>_factory.rb
. (with the _factory
suffix) would help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve of deleting guidelines in general, so LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also prefer splitting factories.rb
when it reaches a certain size. As each project will have its own needs, I like the idea of not specifying anything on the guides.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this change
From my experience working with projects using FactoryBot, this guideline is not something we follow. When asking the opinion of others at thoughtbot, they agreed they prefer to split up factories into their own individual files as this makes it easier to navigate and find them, as opposed to having to look for factories in a big file.
This guideline was first introduced 11 years ago (commit) and we have learned a lot since then.
What are your thoughts?