-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Deprecate top_level_group? and test it in a Cop class #1976
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,10 @@ module RSpec | |
module TopLevelGroup | ||
extend RuboCop::NodePattern::Macros | ||
|
||
DEPRECATED_MODULE_METHOD_WARNING = | ||
'top_level_group? is deprecated and will be ' \ | ||
'removed in the next major version of rubocop_rspec.' | ||
|
||
def on_new_investigation | ||
super | ||
|
||
|
@@ -28,7 +32,10 @@ def on_top_level_example_group(_node); end | |
|
||
def on_top_level_group(_node); end | ||
|
||
# @private | ||
# @deprecated All callers of this method have been removed. | ||
def top_level_group?(node) | ||
warn DEPRECATED_MODULE_METHOD_WARNING, uplevel: 1 | ||
top_level_groups.include?(node) | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something feels off about the Unrelated to this PR, just an observation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like more specs are needed! |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::Cop::RSpec::TopLevelGroup do | ||
describe '#top_level_group?' do | ||
let(:stub_class) do | ||
Class.new do | ||
include RuboCop::Cop::RSpec::TopLevelGroup | ||
|
||
def initialize | ||
@top_level_groups = [] | ||
end | ||
|
||
def test_top_level_group | ||
top_level_group?(nil) | ||
end | ||
end | ||
end | ||
|
||
it 'warns because it is deprecated' do | ||
expect { stub_class.new.test_top_level_group }.to \ | ||
output(/warning: top_level_group\? is deprecated/).to_stderr | ||
end | ||
end | ||
end |
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 more a reminder for us not to forget to remove in 4.0
Should we file a ticket?
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.
Like an Issue? Or is there an internal ticketing system?
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 added the
@deprecated
declaration, but I'm still not sure what filing a ticket entails.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.
Yeah, we just use issues. I created a
4.0
milestone and opened #1986.