-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Lint Factories #568
Comments
I will start looking into this |
Yes, I just tried importing spree factories into an app to use for testing, and the app lints all factories by default when all specs are run. It came up with these errors (after I modified the default user factory to have an 8 character password):
One or two of them look like expected errors, and a couple are only conflicts when multiple factories are run (although it would be nice if uniqueness wasn't violated in that case). A number of the others look like actually invalid factories. |
Right now, there is only five invalid factories left:
Some of these are probably not easy fixes. Who takes on the challenge? |
Working on it! |
@AlessioRocco what progress have you made here? I also started looking at this. As I investigated further, I came to think more and more that FactoryGirl may not be the right tool for us. Take for example, the simple act of adding a line item to order. Using FactoryGirl to Now if we don't care about that extra behavior, that's fine. But then I'm not sure we shouldn't just be using test doubles and avoid the complexities and performance hits of Right now we seem to be somewhere in between those two worlds: we don't really execute the same behavior in tests as we would in a store, but we do try and recreate some of that behavior. What are your thoughts? |
@bbuchalter for now I'm working on a good way to break the specs or notify the developer if we have some "bad" or not tested factories, for now I've just added the linter 670c105 at the beginning of our test suite but more I understand about Factory in Solidus and more I think it's not a good solution, this is a duplication of what we do with About your thoughts on "FactoryGirl may not be the right tool" I understand your point of view and I agree, for now I think that for mimic the store behavior we could use the method that Solidus give to us in the Factory as much as possible, for example the @mamhoff I think that some factories are invalid just because the linter was run two or more times, for example the |
@AlessioRocco thanks for the thoughtful reply. I'm glad to hear that you feel the idea of using Solidus's API for setting up state for factories is a good one. However, on the other hand, I don't want to be optimizing factories in isolation. I'd rather see them improved in the context of making other specs more correct, or more maintainable. Does that make sense? Do you have any specs in mind that would benefit greatly from improved factories? |
@bbuchalter I'm not sure we should be using the Solidus API for setting up test data, mostly because those factories are used in client stores where they might very well use external services to set up shipments or taxes, which would slow down many client test suites. This would mean sample data would actually test production code, leading to hard-to-debug spec setups I think. |
Hey gang, this issue is almost 5 years old, and hasn't had an update in almost 3 years. I think we should consider closing this - if it's still something we want to work on, maybe we can create a new issue outlining the current state of things. I imagine almost everything written here is completely outdated. Thanks! |
I believe #3647 should close this issue. All factories (except one, notated in the PR) pass linting 🎉 |
We should run all our factories through FactoryGirl.lint, as discussed on Slack I highly suspect we won't pass.
This should be a task accomplish-able by anyone with medium ruby/rails/factory girl experience, but could get very tricky depending on which factories don't build.
The text was updated successfully, but these errors were encountered: