-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Fix a false positive for RSpec/DescribedClass
when SkipBlocks
is true and numblocks are used
#2054
base: master
Are you sure you want to change the base?
Conversation
50c3e9a
to
6ff1c39
Compare
expect_offense(<<~RUBY) | ||
describe MyClass do | ||
controller(ApplicationController) do | ||
_1 |
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 is the real-world use case for this?
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 is just here to make the block
node into a numblock
node. Since this is a user-defined method it can yield as much or as little as it wants and the user can use a few ways to express that. It just aligns it to work for all types of blocks there are (currently foo {}
, foo { |bar| }
and foo { _1 }
, but also foo { it }
in the future from Ruby 3.4).
I made the spec a bit more aligned to how could look like in actual code.
describe MyClass do | ||
controller(ApplicationController) do | ||
_1 | ||
bar = MyClass |
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.
Is this a setter? Doesn’t it need to be prefixed with self.
?
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 just moved this over from the test preceeding it. I added the prefix to both to make more sense
…true and numblocks are used
6ff1c39
to
0451790
Compare
I will probably make a few more of these. I don't particularly care about numblocks, this just future-proofs it for
itblock
.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).