-
Notifications
You must be signed in to change notification settings - Fork 481
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
feat: add rubocop to enforce webmocks are enabled only after test_helper #58404
Conversation
relaying from discussion in the infra checkin - is there a way to simply enforce that all implementation code happens after imports? |
By implementation code, are you referring to the code in |
Nah, just speaking in super general terms. Similar to how we have added import order rules to our frontend code, is there a linting solution here that would require |
I think that makes sense for the most part. However, there are some uncommon Perhaps we can discuss this more at developer tools working group? For now, we can clean up and prevent this test build failure from happening again on these 7 tests. Existing usages for
|
LGTM but would love input from someone in the code more often than me. |
I think this approach is probably good enough. IIRC we run lint in the following scenarios:
in the future, if we start including webmock so often that we want to move it into test_helper.rb, then it seems like we could instead do something like this in test_helper.rb:
|
a 3rd option would be to write our own cdo/webmock.rb wrapper which does all the necessary setup and requires webmock, and then we can add a lint rule which disallows requiring webmock directly from outside of this wrapper. |
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.
just clarifying I think this option looks good as is :-) the other options are to keep in mind for the future
When using webmock to mock out web requests, webmock will error if any live web request is made without being stubbed.
test_helper
does make web requests and will therefore cause webmock to fail. Iftest_helper
is initialized by another a test, the webmock will not fail.To ensure consistency, ensure that
test_helper
is required prior towebmock
.Links
Testing story
Ran rubocop and autocorrect, spot inspection.
Deployment strategy
Follow-up work
Privacy
Security
Caching
PR Checklist: