Skip to content

Commit

Permalink
Replace Cop with Base in tests to prepare for deprecating Cop.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvandersluis authored and bbatsov committed Sep 28, 2021
1 parent 1ea71be commit 3a13e1d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
6 changes: 3 additions & 3 deletions spec/rubocop/cli/options_spec.rb
Expand Up @@ -238,7 +238,7 @@
module RuboCop
module Cop
module Style
class SomeCop < Cop
class SomeCop < Base
end
end
end
Expand Down Expand Up @@ -330,7 +330,7 @@ class SomeCop < Cop
module RuboCop
module Cop
module Style
class SomeCop < Cop
class SomeCop < Base
end
end
end
Expand Down Expand Up @@ -378,7 +378,7 @@ class SomeCop < Cop
module RuboCop
module Cop
module Style
class SomeCop < Cop
class SomeCop < Base
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rubocop/config_loader_spec.rb
Expand Up @@ -736,7 +736,7 @@ def enabled?(cop)
module RuboCop
module Cop
module Custom
class Loop < Cop
class Loop < Base
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/rubocop/cop/internal_affairs/undefined_config_spec.rb
Expand Up @@ -192,6 +192,7 @@ def configured?
RUBY
end

# TODO: Remove this test when the `Cop` base class is removed
it 'works when the base class is `Cop` instead of `Base`' do
expect_offense(<<~RUBY)
module RuboCop
Expand Down
12 changes: 6 additions & 6 deletions spec/support/cops/class_must_be_a_module_cop.rb
Expand Up @@ -3,13 +3,13 @@
module RuboCop
module Cop
module Test
class ClassMustBeAModuleCop < RuboCop::Cop::Cop # rubocop:disable InternalAffairs/InheritDeprecatedCopClass
def on_class(node)
add_offense(node, message: 'Class must be a Module')
end
class ClassMustBeAModuleCop < RuboCop::Cop::Base
extend AutoCorrector

def autocorrect(node)
->(corrector) { corrector.replace(node.loc.keyword, 'module') }
def on_class(node)
add_offense(node, message: 'Class must be a Module') do |corrector|
corrector.replace(node.loc.keyword, 'module')
end
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/support/cops/module_must_be_a_class_cop.rb
Expand Up @@ -3,13 +3,13 @@
module RuboCop
module Cop
module Test
class ModuleMustBeAClassCop < RuboCop::Cop::Cop # rubocop:disable InternalAffairs/InheritDeprecatedCopClass
def on_module(node)
add_offense(node, message: 'Module must be a Class')
end
class ModuleMustBeAClassCop < RuboCop::Cop::Base
extend AutoCorrector

def autocorrect(node)
->(corrector) { corrector.replace(node.loc.keyword, 'class') }
def on_module(node)
add_offense(node, message: 'Module must be a Class') do |corrector|
corrector.replace(node.loc.keyword, 'class')
end
end
end
end
Expand Down

0 comments on commit 3a13e1d

Please sign in to comment.