Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/prefer_class_methods_over_module_spec.rb')
-rw-r--r--spec/rubocop/cop/prefer_class_methods_over_module_spec.rb42
1 files changed, 12 insertions, 30 deletions
diff --git a/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb b/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
index dc665f9dd25..5a557ec26d6 100644
--- a/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
+++ b/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
@@ -2,15 +2,12 @@
require 'fast_spec_helper'
require 'rubocop'
-require 'rubocop/rspec/support'
require_relative '../../../rubocop/cop/prefer_class_methods_over_module'
RSpec.describe RuboCop::Cop::PreferClassMethodsOverModule do
- include CopHelper
-
subject(:cop) { described_class.new }
- it 'flags violation when using module ClassMethods' do
+ it 'flags violation when using module ClassMethods and corrects', :aggregate_failures do
expect_offense(<<~RUBY)
module Foo
extend ActiveSupport::Concern
@@ -22,6 +19,17 @@ RSpec.describe RuboCop::Cop::PreferClassMethodsOverModule do
end
end
RUBY
+
+ expect_correction(<<~RUBY)
+ module Foo
+ extend ActiveSupport::Concern
+
+ class_methods do
+ def a_class_method
+ end
+ end
+ end
+ RUBY
end
it "doesn't flag violation when using class_methods" do
@@ -69,30 +77,4 @@ RSpec.describe RuboCop::Cop::PreferClassMethodsOverModule do
end
RUBY
end
-
- it 'autocorrects ClassMethods into class_methods' do
- source = <<~RUBY
- module Foo
- extend ActiveSupport::Concern
-
- module ClassMethods
- def a_class_method
- end
- end
- end
- RUBY
- autocorrected = autocorrect_source(source)
-
- expected_source = <<~RUBY
- module Foo
- extend ActiveSupport::Concern
-
- class_methods do
- def a_class_method
- end
- end
- end
- RUBY
- expect(autocorrected).to eq(expected_source)
- end
end