-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Refactor for RSpec/BeforeAfterAll
#1739
Conversation
@@ -30,11 +30,11 @@ class BeforeAfterAll < Base | |||
'`use_transactional_fixtures` is enabled, then records created ' \ | |||
'in `%<hook>s` are not automatically rolled back.' | |||
|
|||
RESTRICT_ON_SEND = %i[before after].freeze | |||
RESTRICT_ON_SEND = Set[:before, :after].freeze |
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.
what's the reason to use a set?
Seems that for the majority of cops we use %i. If we prefer set:
- we need to update the rest of the cops
- we can provide a check in the internal investigations that RESTRICT_ON_SEND is defined as Set
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.
This was to make it easier to reuse in def_node_matcher
. If we use %i
, it would have to be something like {:#{RESTRICT_ON_SEND.join(' :')}}
, wouldn't it?
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.
Ah I see. Thank you 👍
|
||
# @!method before_or_after_all(node) | ||
def_node_matcher :before_or_after_all, <<-PATTERN | ||
$(send _ {:before :after} (sym {:all :context})) | ||
$(send _ RESTRICT_ON_SEND (sym {:all :context})) |
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.
makes sense to reuse 👍
- Use `Set[...]` instead of %i[...] - Use RESTRICT_ON_SEND in def_node_matcher
Thank you! |
Set[...]
instead of %i[...]Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).