diff options
Diffstat (limited to 'spec/rubocop')
83 files changed, 367 insertions, 316 deletions
diff --git a/spec/rubocop/code_reuse_helpers_spec.rb b/spec/rubocop/code_reuse_helpers_spec.rb index 2720141aad2..574a4a85a34 100644 --- a/spec/rubocop/code_reuse_helpers_spec.rb +++ b/spec/rubocop/code_reuse_helpers_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'parser/current' require_relative '../../rubocop/code_reuse_helpers' -describe RuboCop::CodeReuseHelpers do +RSpec.describe RuboCop::CodeReuseHelpers do def parse_source(source, path = 'foo.rb') buffer = Parser::Source::Buffer.new(path) buffer.source = source @@ -69,13 +69,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_finder?' do it 'returns true for a node in the finders directory' do - node = parse_source('10', Rails.root.join('app', 'finders', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'finders', 'foo.rb')) expect(cop.in_finder?(node)).to eq(true) end it 'returns false for a node outside the finders directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_finder?(node)).to eq(false) end @@ -83,13 +83,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_model?' do it 'returns true for a node in the models directory' do - node = parse_source('10', Rails.root.join('app', 'models', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'models', 'foo.rb')) expect(cop.in_model?(node)).to eq(true) end it 'returns false for a node outside the models directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_model?(node)).to eq(false) end @@ -97,13 +97,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_service_class?' do it 'returns true for a node in the services directory' do - node = parse_source('10', Rails.root.join('app', 'services', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'services', 'foo.rb')) expect(cop.in_service_class?(node)).to eq(true) end it 'returns false for a node outside the services directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_service_class?(node)).to eq(false) end @@ -111,13 +111,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_presenter?' do it 'returns true for a node in the presenters directory' do - node = parse_source('10', Rails.root.join('app', 'presenters', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'presenters', 'foo.rb')) expect(cop.in_presenter?(node)).to eq(true) end it 'returns false for a node outside the presenters directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_presenter?(node)).to eq(false) end @@ -125,13 +125,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_serializer?' do it 'returns true for a node in the serializers directory' do - node = parse_source('10', Rails.root.join('app', 'serializers', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'serializers', 'foo.rb')) expect(cop.in_serializer?(node)).to eq(true) end it 'returns false for a node outside the serializers directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_serializer?(node)).to eq(false) end @@ -139,13 +139,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_worker?' do it 'returns true for a node in the workers directory' do - node = parse_source('10', Rails.root.join('app', 'workers', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'workers', 'foo.rb')) expect(cop.in_worker?(node)).to eq(true) end it 'returns false for a node outside the workers directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_worker?(node)).to eq(false) end @@ -153,13 +153,13 @@ describe RuboCop::CodeReuseHelpers do describe '#in_api?' do it 'returns true for a node in the API directory' do - node = parse_source('10', Rails.root.join('lib', 'api', 'foo.rb')) + node = parse_source('10', rails_root_join('lib', 'api', 'foo.rb')) expect(cop.in_api?(node)).to eq(true) end it 'returns false for a node outside the API directory' do - node = parse_source('10', Rails.root.join('lib', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('lib', 'foo', 'foo.rb')) expect(cop.in_api?(node)).to eq(false) end @@ -167,21 +167,21 @@ describe RuboCop::CodeReuseHelpers do describe '#in_directory?' do it 'returns true for a directory in the CE app/ directory' do - node = parse_source('10', Rails.root.join('app', 'models', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'models', 'foo.rb')) expect(cop.in_directory?(node, 'models')).to eq(true) end it 'returns true for a directory in the EE app/ directory' do node = - parse_source('10', Rails.root.join('ee', 'app', 'models', 'foo.rb')) + parse_source('10', rails_root_join('ee', 'app', 'models', 'foo.rb')) expect(cop.in_directory?(node, 'models')).to eq(true) end it 'returns false for a directory in the lib/ directory' do node = - parse_source('10', Rails.root.join('lib', 'models', 'foo.rb')) + parse_source('10', rails_root_join('lib', 'models', 'foo.rb')) expect(cop.in_directory?(node, 'models')).to eq(false) end diff --git a/spec/rubocop/cop/active_record_association_reload_spec.rb b/spec/rubocop/cop/active_record_association_reload_spec.rb index d9c8069f0c3..79053a79c5a 100644 --- a/spec/rubocop/cop/active_record_association_reload_spec.rb +++ b/spec/rubocop/cop/active_record_association_reload_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require_relative '../../../rubocop/cop/active_record_association_reload' -describe RuboCop::Cop::ActiveRecordAssociationReload do +RSpec.describe RuboCop::Cop::ActiveRecordAssociationReload, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/api/grape_api_instance_spec.rb b/spec/rubocop/cop/api/grape_api_instance_spec.rb new file mode 100644 index 00000000000..74f175cb707 --- /dev/null +++ b/spec/rubocop/cop/api/grape_api_instance_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' +require 'rubocop' +require_relative '../../../../rubocop/cop/api/grape_api_instance' + +RSpec.describe RuboCop::Cop::API::GrapeAPIInstance do + include CopHelper + + subject(:cop) { described_class.new } + + it 'adds an offense when inheriting from Grape::API' do + inspect_source(<<~CODE) + class SomeAPI < Grape::API + end + CODE + + expect(cop.offenses.size).to eq(1) + end + + it 'does not add an offense when inheriting from Grape::API::Instance' do + inspect_source(<<~CODE) + class SomeAPI < Grape::API::Instance + end + CODE + + expect(cop.offenses.size).to be_zero + end +end diff --git a/spec/rubocop/cop/api/grape_array_missing_coerce_spec.rb b/spec/rubocop/cop/api/grape_array_missing_coerce_spec.rb new file mode 100644 index 00000000000..c7bb8255398 --- /dev/null +++ b/spec/rubocop/cop/api/grape_array_missing_coerce_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' +require 'rubocop' +require_relative '../../../../rubocop/cop/api/grape_array_missing_coerce' + +RSpec.describe RuboCop::Cop::API::GrapeArrayMissingCoerce do + include CopHelper + + subject(:cop) { described_class.new } + + it 'adds an offense with a required parameter' do + inspect_source(<<~CODE) + class SomeAPI < Grape::API::Instance + params do + requires :values, type: Array[String] + end + end + CODE + + expect(cop.offenses.size).to eq(1) + end + + it 'adds an offense with an optional parameter' do + inspect_source(<<~CODE) + class SomeAPI < Grape::API::Instance + params do + optional :values, type: Array[String] + end + end + CODE + + expect(cop.offenses.size).to eq(1) + end + + it 'does not add an offense' do + inspect_source(<<~CODE) + class SomeAPI < Grape::API::Instance + params do + requires :values, type: Array[String], coerce_with: ->(val) { val.split(',').map(&:strip) } + requires :milestone, type: String, desc: 'Milestone title' + optional :assignee_id, types: [Integer, String], integer_none_any: true, + desc: 'Return issues which are assigned to the user with the given ID' + end + end + CODE + + expect(cop.offenses.size).to be_zero + end + + it 'does not add an offense for unrelated classes' do + inspect_source(<<~CODE) + class SomeClass + params do + requires :values, type: Array[String] + end + end + CODE + + expect(cop.offenses.size).to be_zero + end +end diff --git a/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb b/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb index feb85c354ef..bc9db9cafec 100644 --- a/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb +++ b/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb @@ -5,7 +5,7 @@ require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/avoid_break_from_strong_memoize' -describe RuboCop::Cop::AvoidBreakFromStrongMemoize do +RSpec.describe RuboCop::Cop::AvoidBreakFromStrongMemoize do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb b/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb index 11d63d8e0ee..851493e004e 100644 --- a/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb +++ b/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers' -describe RuboCop::Cop::AvoidKeywordArgumentsInSidekiqWorkers do +RSpec.describe RuboCop::Cop::AvoidKeywordArgumentsInSidekiqWorkers, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/avoid_return_from_blocks_spec.rb b/spec/rubocop/cop/avoid_return_from_blocks_spec.rb index 919cd3d98f3..9e571bf96b9 100644 --- a/spec/rubocop/cop/avoid_return_from_blocks_spec.rb +++ b/spec/rubocop/cop/avoid_return_from_blocks_spec.rb @@ -5,7 +5,7 @@ require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/avoid_return_from_blocks' -describe RuboCop::Cop::AvoidReturnFromBlocks do +RSpec.describe RuboCop::Cop::AvoidReturnFromBlocks do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb index 207c3420fbd..78bc859beda 100644 --- a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb +++ b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require_relative '../../../rubocop/cop/avoid_route_redirect_leading_slash' -describe RuboCop::Cop::AvoidRouteRedirectLeadingSlash do +RSpec.describe RuboCop::Cop::AvoidRouteRedirectLeadingSlash, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/ban_catch_throw_spec.rb b/spec/rubocop/cop/ban_catch_throw_spec.rb index b4c277fc429..1d0ccb6d262 100644 --- a/spec/rubocop/cop/ban_catch_throw_spec.rb +++ b/spec/rubocop/cop/ban_catch_throw_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/ban_catch_throw' -describe RuboCop::Cop::BanCatchThrow do +RSpec.describe RuboCop::Cop::BanCatchThrow, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/code_reuse/active_record_spec.rb b/spec/rubocop/cop/code_reuse/active_record_spec.rb index 0f3d886e4b8..25eca185f26 100644 --- a/spec/rubocop/cop/code_reuse/active_record_spec.rb +++ b/spec/rubocop/cop/code_reuse/active_record_spec.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/code_reuse/active_record' -describe RuboCop::Cop::CodeReuse::ActiveRecord do +RSpec.describe RuboCop::Cop::CodeReuse::ActiveRecord, type: :rubocop do include CopHelper subject(:cop) { described_class.new } @@ -46,7 +45,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do end it 'does not flag the use of ActiveRecord models in a model' do - path = Rails.root.join('app', 'models', 'foo.rb').to_s + path = rails_root_join('app', 'models', 'foo.rb').to_s expect_no_offenses(<<~SOURCE, path) def foo @@ -56,7 +55,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do end it 'does not flag the use of ActiveRecord models in a spec' do - path = Rails.root.join('spec', 'foo_spec.rb').to_s + path = rails_root_join('spec', 'foo_spec.rb').to_s expect_no_offenses(<<~SOURCE, path) def foo @@ -66,10 +65,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do end it 'does not flag the use of ActiveRecord models in a background migration' do - path = Rails - .root - .join('lib', 'gitlab', 'background_migration', 'foo.rb') - .to_s + path = rails_root_join('lib', 'gitlab', 'background_migration', 'foo.rb').to_s expect_no_offenses(<<~SOURCE, path) def foo @@ -79,7 +75,7 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do end it 'does not flag the use of ActiveRecord models in lib/gitlab/database' do - path = Rails.root.join('lib', 'gitlab', 'database', 'foo.rb').to_s + path = rails_root_join('lib', 'gitlab', 'database', 'foo.rb').to_s expect_no_offenses(<<~SOURCE, path) def foo diff --git a/spec/rubocop/cop/code_reuse/finder_spec.rb b/spec/rubocop/cop/code_reuse/finder_spec.rb index b04e053a4c3..1935d825b19 100644 --- a/spec/rubocop/cop/code_reuse/finder_spec.rb +++ b/spec/rubocop/cop/code_reuse/finder_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/code_reuse/finder' -describe RuboCop::Cop::CodeReuse::Finder do +RSpec.describe RuboCop::Cop::CodeReuse::Finder, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/code_reuse/presenter_spec.rb b/spec/rubocop/cop/code_reuse/presenter_spec.rb index 4fe72619273..1366018ec12 100644 --- a/spec/rubocop/cop/code_reuse/presenter_spec.rb +++ b/spec/rubocop/cop/code_reuse/presenter_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/code_reuse/presenter' -describe RuboCop::Cop::CodeReuse::Presenter do +RSpec.describe RuboCop::Cop::CodeReuse::Presenter, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/code_reuse/serializer_spec.rb b/spec/rubocop/cop/code_reuse/serializer_spec.rb index 4530b15eed7..d4341cc0367 100644 --- a/spec/rubocop/cop/code_reuse/serializer_spec.rb +++ b/spec/rubocop/cop/code_reuse/serializer_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/code_reuse/serializer' -describe RuboCop::Cop::CodeReuse::Serializer do +RSpec.describe RuboCop::Cop::CodeReuse::Serializer, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/code_reuse/service_class_spec.rb b/spec/rubocop/cop/code_reuse/service_class_spec.rb index 7b8d82f332e..b018e743230 100644 --- a/spec/rubocop/cop/code_reuse/service_class_spec.rb +++ b/spec/rubocop/cop/code_reuse/service_class_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/code_reuse/service_class' -describe RuboCop::Cop::CodeReuse::ServiceClass do +RSpec.describe RuboCop::Cop::CodeReuse::ServiceClass, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/code_reuse/worker_spec.rb b/spec/rubocop/cop/code_reuse/worker_spec.rb index 97acaeb7643..1f502e554c4 100644 --- a/spec/rubocop/cop/code_reuse/worker_spec.rb +++ b/spec/rubocop/cop/code_reuse/worker_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/code_reuse/worker' -describe RuboCop::Cop::CodeReuse::Worker do +RSpec.describe RuboCop::Cop::CodeReuse::Worker, type: :rubocop do include CopHelper subject(:cop) { described_class.new } @@ -31,7 +31,7 @@ describe RuboCop::Cop::CodeReuse::Worker do .and_return(true) expect_offense(<<~SOURCE) - class Foo < Grape::API + class Foo < Grape::API::Instance resource :projects do get '/' do FooWorker.perform_async diff --git a/spec/rubocop/cop/default_scope_spec.rb b/spec/rubocop/cop/default_scope_spec.rb index 9520915f900..617a7f63497 100644 --- a/spec/rubocop/cop/default_scope_spec.rb +++ b/spec/rubocop/cop/default_scope_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/default_scope' -describe RuboCop::Cop::DefaultScope do +RSpec.describe RuboCop::Cop::DefaultScope, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/destroy_all_spec.rb b/spec/rubocop/cop/destroy_all_spec.rb index d06c0b2f3cf..3220d44ea2b 100644 --- a/spec/rubocop/cop/destroy_all_spec.rb +++ b/spec/rubocop/cop/destroy_all_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/destroy_all' -describe RuboCop::Cop::DestroyAll do +RSpec.describe RuboCop::Cop::DestroyAll, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/filename_length_spec.rb b/spec/rubocop/cop/filename_length_spec.rb index b1cc845787a..381218c61ed 100644 --- a/spec/rubocop/cop/filename_length_spec.rb +++ b/spec/rubocop/cop/filename_length_spec.rb @@ -5,7 +5,7 @@ require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/filename_length' -describe RuboCop::Cop::FilenameLength, type: :rubocop do +RSpec.describe RuboCop::Cop::FilenameLength, type: :rubocop do subject(:cop) { described_class.new } it 'does not flag files with names 100 characters long' do diff --git a/spec/rubocop/cop/gitlab/bulk_insert_spec.rb b/spec/rubocop/cop/gitlab/bulk_insert_spec.rb index 937c709218f..2766e4f1982 100644 --- a/spec/rubocop/cop/gitlab/bulk_insert_spec.rb +++ b/spec/rubocop/cop/gitlab/bulk_insert_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/bulk_insert' -describe RuboCop::Cop::Gitlab::BulkInsert do +RSpec.describe RuboCop::Cop::Gitlab::BulkInsert, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/change_timezone_spec.rb b/spec/rubocop/cop/gitlab/change_timezone_spec.rb index 1e4b4048cf4..1ec5f28e811 100644 --- a/spec/rubocop/cop/gitlab/change_timezone_spec.rb +++ b/spec/rubocop/cop/gitlab/change_timezone_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/change_timzone' -describe RuboCop::Cop::Gitlab::ChangeTimezone do +RSpec.describe RuboCop::Cop::Gitlab::ChangeTimezone, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb index bf0434e7afe..97ed6b743f9 100644 --- a/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb +++ b/spec/rubocop/cop/gitlab/const_get_inherit_false_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/const_get_inherit_false' -describe RuboCop::Cop::Gitlab::ConstGetInheritFalse do +RSpec.describe RuboCop::Cop::Gitlab::ConstGetInheritFalse, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb index 3a0a74a4713..1ed21e44290 100644 --- a/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb +++ b/spec/rubocop/cop/gitlab/duplicate_spec_location_spec.rb @@ -2,12 +2,10 @@ require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/duplicate_spec_location' -describe RuboCop::Cop::Gitlab::DuplicateSpecLocation do - include RuboCop::RSpec::ExpectOffense +RSpec.describe RuboCop::Cop::Gitlab::DuplicateSpecLocation, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb index 7af98b66218..30ee422f420 100644 --- a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb +++ b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/finder_with_find_by' -describe RuboCop::Cop::Gitlab::FinderWithFindBy do +RSpec.describe RuboCop::Cop::Gitlab::FinderWithFindBy, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/httparty_spec.rb b/spec/rubocop/cop/gitlab/httparty_spec.rb index 42da97679ec..379365096ba 100644 --- a/spec/rubocop/cop/gitlab/httparty_spec.rb +++ b/spec/rubocop/cop/gitlab/httparty_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/httparty' -describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath +RSpec.describe RuboCop::Cop::Gitlab::HTTParty, type: :rubocop do # rubocop:disable RSpec/FilePath include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/json_spec.rb b/spec/rubocop/cop/gitlab/json_spec.rb index d64f60c8583..6f5ec07ffb1 100644 --- a/spec/rubocop/cop/gitlab/json_spec.rb +++ b/spec/rubocop/cop/gitlab/json_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/json' -describe RuboCop::Cop::Gitlab::Json do +RSpec.describe RuboCop::Cop::Gitlab::Json, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb b/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb index 9cb55ced1fa..3d22201c92e 100644 --- a/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb +++ b/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/module_with_instance_variables' -describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do +RSpec.describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb index ae9466368d2..ebe984b189d 100644 --- a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb +++ b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/predicate_memoization' -describe RuboCop::Cop::Gitlab::PredicateMemoization do +RSpec.describe RuboCop::Cop::Gitlab::PredicateMemoization, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/rails_logger_spec.rb b/spec/rubocop/cop/gitlab/rails_logger_spec.rb index f0158ddcc5c..0583079136b 100644 --- a/spec/rubocop/cop/gitlab/rails_logger_spec.rb +++ b/spec/rubocop/cop/gitlab/rails_logger_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/rails_logger' -describe RuboCop::Cop::Gitlab::RailsLogger do +RSpec.describe RuboCop::Cop::Gitlab::RailsLogger, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/gitlab/union_spec.rb b/spec/rubocop/cop/gitlab/union_spec.rb index f0544fdb66e..571dcc4eeb4 100644 --- a/spec/rubocop/cop/gitlab/union_spec.rb +++ b/spec/rubocop/cop/gitlab/union_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/gitlab/union' -describe RuboCop::Cop::Gitlab::Union do +RSpec.describe RuboCop::Cop::Gitlab::Union, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/graphql/authorize_types_spec.rb b/spec/rubocop/cop/graphql/authorize_types_spec.rb index 98797a780e0..df637a26ec5 100644 --- a/spec/rubocop/cop/graphql/authorize_types_spec.rb +++ b/spec/rubocop/cop/graphql/authorize_types_spec.rb @@ -2,92 +2,68 @@ require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' + require_relative '../../../../rubocop/cop/graphql/authorize_types' -describe RuboCop::Cop::Graphql::AuthorizeTypes do - include RuboCop::RSpec::ExpectOffense +RSpec.describe RuboCop::Cop::Graphql::AuthorizeTypes, type: :rubocop do include CopHelper subject(:cop) { described_class.new } - context 'when NOT in a type folder' do - before do - allow(cop).to receive(:in_type?).and_return(false) - end - - it 'does not add an offense even though there is no authorize call' do - expect_no_offenses(<<~TYPE.strip) - module Types - class AType < BaseObject - field :a_thing - field :another_thing - end - end - TYPE - end - end - - context 'when in a type folder' do - before do - allow(cop).to receive(:in_type?).and_return(true) - end - - it 'adds an offense when there is no authorize call' do - inspect_source(<<~TYPE) - module Types - class AType < BaseObject - field :a_thing - field :another_thing - end + it 'adds an offense when there is no authorize call' do + inspect_source(<<~TYPE) + module Types + class AType < BaseObject + field :a_thing + field :another_thing end - TYPE + end + TYPE - expect(cop.offenses.size).to eq 1 - end + expect(cop.offenses.size).to eq 1 + end - it 'does not add an offense for classes that have an authorize call' do - expect_no_offenses(<<~TYPE.strip) - module Types - class AType < BaseObject - graphql_name 'ATypeName' + it 'does not add an offense for classes that have an authorize call' do + expect_no_offenses(<<~TYPE.strip) + module Types + class AType < BaseObject + graphql_name 'ATypeName' - authorize :an_ability, :second_ability + authorize :an_ability, :second_ability - field :a_thing - end + field :a_thing end - TYPE - end + end + TYPE + end - it 'does not add an offense for classes that only have an authorize call' do - expect_no_offenses(<<~TYPE.strip) - module Types - class AType < SuperClassWithFields - authorize :an_ability - end + it 'does not add an offense for classes that only have an authorize call' do + expect_no_offenses(<<~TYPE.strip) + module Types + class AType < SuperClassWithFields + authorize :an_ability end - TYPE - end + end + TYPE + end - it 'does not add an offense for base types' do - expect_no_offenses(<<~TYPE) - module Types - class AType < BaseEnum - field :a_thing - end + it 'does not add an offense for base types' do + expect_no_offenses(<<~TYPE) + module Types + class AType < BaseEnum + field :a_thing end - TYPE - end + end + TYPE + end - it 'does not add an offense for Enums' do - expect_no_offenses(<<~TYPE) - module Types - class ATypeEnum < AnotherEnum - field :a_thing - end + it 'does not add an offense for Enums' do + expect_no_offenses(<<~TYPE) + module Types + class ATypeEnum < AnotherEnum + field :a_thing end - TYPE - end + end + TYPE end end diff --git a/spec/rubocop/cop/graphql/descriptions_spec.rb b/spec/rubocop/cop/graphql/descriptions_spec.rb index 8cfdc05172d..3b29cd2fbee 100644 --- a/spec/rubocop/cop/graphql/descriptions_spec.rb +++ b/spec/rubocop/cop/graphql/descriptions_spec.rb @@ -2,11 +2,9 @@ require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/graphql/descriptions' -describe RuboCop::Cop::Graphql::Descriptions do - include RuboCop::RSpec::ExpectOffense +RSpec.describe RuboCop::Cop::Graphql::Descriptions, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb b/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb index 8e027ad59f7..4e725deaafd 100644 --- a/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb +++ b/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/group_public_or_visible_to_user' -describe RuboCop::Cop::GroupPublicOrVisibleToUser do +RSpec.describe RuboCop::Cop::GroupPublicOrVisibleToUser, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/ignored_columns_spec.rb b/spec/rubocop/cop/ignored_columns_spec.rb index 64437765018..ec5499bbdff 100644 --- a/spec/rubocop/cop/ignored_columns_spec.rb +++ b/spec/rubocop/cop/ignored_columns_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/ignored_columns' -describe RuboCop::Cop::IgnoredColumns do +RSpec.describe RuboCop::Cop::IgnoredColumns, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/include_sidekiq_worker_spec.rb b/spec/rubocop/cop/include_sidekiq_worker_spec.rb index 39965646aff..8d056c6a13e 100644 --- a/spec/rubocop/cop/include_sidekiq_worker_spec.rb +++ b/spec/rubocop/cop/include_sidekiq_worker_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/include_sidekiq_worker' -describe RuboCop::Cop::IncludeSidekiqWorker do +RSpec.describe RuboCop::Cop::IncludeSidekiqWorker, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb b/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb index f047baa3bc2..767ed994542 100644 --- a/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb +++ b/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/inject_enterprise_edition_module' -describe RuboCop::Cop::InjectEnterpriseEditionModule do +RSpec.describe RuboCop::Cop::InjectEnterpriseEditionModule, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/line_break_around_conditional_block_spec.rb b/spec/rubocop/cop/line_break_around_conditional_block_spec.rb index d09de4c6614..0a26ef49e35 100644 --- a/spec/rubocop/cop/line_break_around_conditional_block_spec.rb +++ b/spec/rubocop/cop/line_break_around_conditional_block_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/line_break_around_conditional_block' -describe RuboCop::Cop::LineBreakAroundConditionalBlock do +RSpec.describe RuboCop::Cop::LineBreakAroundConditionalBlock, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_column_with_default_spec.rb b/spec/rubocop/cop/migration/add_column_with_default_spec.rb index 5d4fc59fb95..50af344e0d4 100644 --- a/spec/rubocop/cop/migration/add_column_with_default_spec.rb +++ b/spec/rubocop/cop/migration/add_column_with_default_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_column_with_default' -describe RuboCop::Cop::Migration::AddColumnWithDefault do +RSpec.describe RuboCop::Cop::Migration::AddColumnWithDefault, type: :rubocop do include CopHelper let(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb b/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb index 5b179168eab..6ae4fb21126 100644 --- a/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb +++ b/spec/rubocop/cop/migration/add_columns_to_wide_tables_spec.rb @@ -1,11 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' - require_relative '../../../../rubocop/cop/migration/add_columns_to_wide_tables' -describe RuboCop::Cop::Migration::AddColumnsToWideTables do +RSpec.describe RuboCop::Cop::Migration::AddColumnsToWideTables, type: :rubocop do include CopHelper let(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb b/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb index dfc3898af24..b43d44dba65 100644 --- a/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb +++ b/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_concurrent_foreign_key' -describe RuboCop::Cop::Migration::AddConcurrentForeignKey do +RSpec.describe RuboCop::Cop::Migration::AddConcurrentForeignKey, type: :rubocop do include CopHelper let(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_concurrent_index_spec.rb b/spec/rubocop/cop/migration/add_concurrent_index_spec.rb index 9812e64216f..cef5295830c 100644 --- a/spec/rubocop/cop/migration/add_concurrent_index_spec.rb +++ b/spec/rubocop/cop/migration/add_concurrent_index_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_concurrent_index' -describe RuboCop::Cop::Migration::AddConcurrentIndex do +RSpec.describe RuboCop::Cop::Migration::AddConcurrentIndex, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_index_spec.rb b/spec/rubocop/cop/migration/add_index_spec.rb index ca1aadb381b..6bb78a7f3c7 100644 --- a/spec/rubocop/cop/migration/add_index_spec.rb +++ b/spec/rubocop/cop/migration/add_index_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_index' -describe RuboCop::Cop::Migration::AddIndex do +RSpec.describe RuboCop::Cop::Migration::AddIndex, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb b/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb index 39ca9ace73d..5f0ca419548 100644 --- a/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb +++ b/spec/rubocop/cop/migration/add_limit_to_text_columns_spec.rb @@ -1,12 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_limit_to_text_columns' -describe RuboCop::Cop::Migration::AddLimitToTextColumns do +RSpec.describe RuboCop::Cop::Migration::AddLimitToTextColumns, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_reference_spec.rb b/spec/rubocop/cop/migration/add_reference_spec.rb index 03348ecc744..fab70d74b55 100644 --- a/spec/rubocop/cop/migration/add_reference_spec.rb +++ b/spec/rubocop/cop/migration/add_reference_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_reference' -describe RuboCop::Cop::Migration::AddReference do +RSpec.describe RuboCop::Cop::Migration::AddReference, type: :rubocop do include CopHelper let(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/add_timestamps_spec.rb b/spec/rubocop/cop/migration/add_timestamps_spec.rb index a3314d878e5..c18b6b06ded 100644 --- a/spec/rubocop/cop/migration/add_timestamps_spec.rb +++ b/spec/rubocop/cop/migration/add_timestamps_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/add_timestamps' -describe RuboCop::Cop::Migration::AddTimestamps do +RSpec.describe RuboCop::Cop::Migration::AddTimestamps, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/datetime_spec.rb b/spec/rubocop/cop/migration/datetime_spec.rb index e3023406dce..c5f6fd503ec 100644 --- a/spec/rubocop/cop/migration/datetime_spec.rb +++ b/spec/rubocop/cop/migration/datetime_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/datetime' -describe RuboCop::Cop::Migration::Datetime do +RSpec.describe RuboCop::Cop::Migration::Datetime, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/drop_table_spec.rb b/spec/rubocop/cop/migration/drop_table_spec.rb index 4fe7fc8c5a5..44a1106ba62 100644 --- a/spec/rubocop/cop/migration/drop_table_spec.rb +++ b/spec/rubocop/cop/migration/drop_table_spec.rb @@ -7,7 +7,7 @@ require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/migration/drop_table' -describe RuboCop::Cop::Migration::DropTable do +RSpec.describe RuboCop::Cop::Migration::DropTable do include CopHelper subject(:cop) { described_class.new } @@ -17,20 +17,70 @@ describe RuboCop::Cop::Migration::DropTable do allow(cop).to receive(:in_deployment_migration?).and_return(true) end - it 'registers an offense' do - expect_offense(<<~PATTERN) - def change - drop_table :table - ^^^^^^^^^^ #{described_class::MSG} - - add_column(:users, :username, :text) + context 'with drop_table DSL method' do + context 'when in down method' do + it 'does not register an offense' do + expect_no_offenses(<<~PATTERN) + def down + drop_table :table + end + PATTERN + end + end - execute "DROP TABLE table" - ^^^^^^^ #{described_class::MSG} + context 'when in up method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def up + drop_table :table + ^^^^^^^^^^ #{described_class::MSG} + end + PATTERN + end + end - execute "CREATE UNIQUE INDEX email_index ON users (email);" + context 'when in change method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def change + drop_table :table + ^^^^^^^^^^ #{described_class::MSG} + end + PATTERN end - PATTERN + end + end + + context 'with DROP TABLE SQL literal' do + it 'does not register an offense' do + expect_no_offenses(<<~PATTERN) + def down + execute "DROP TABLE table" + end + PATTERN + end + end + + context 'when in up method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def up + execute "DROP TABLE table" + ^^^^^^^ #{described_class::MSG} + end + PATTERN + end + end + + context 'when in change method' do + it 'registers an offense' do + expect_offense(<<~PATTERN) + def change + execute "DROP TABLE table" + ^^^^^^^ #{described_class::MSG} + end + PATTERN + end end end diff --git a/spec/rubocop/cop/migration/hash_index_spec.rb b/spec/rubocop/cop/migration/hash_index_spec.rb index e8b05a94653..3d26ea41d08 100644 --- a/spec/rubocop/cop/migration/hash_index_spec.rb +++ b/spec/rubocop/cop/migration/hash_index_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/hash_index' -describe RuboCop::Cop::Migration::HashIndex do +RSpec.describe RuboCop::Cop::Migration::HashIndex, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/prevent_strings_spec.rb b/spec/rubocop/cop/migration/prevent_strings_spec.rb index d0e97874aed..6882dca1926 100644 --- a/spec/rubocop/cop/migration/prevent_strings_spec.rb +++ b/spec/rubocop/cop/migration/prevent_strings_spec.rb @@ -1,12 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/prevent_strings' -describe RuboCop::Cop::Migration::PreventStrings do +RSpec.describe RuboCop::Cop::Migration::PreventStrings, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/remove_column_spec.rb b/spec/rubocop/cop/migration/remove_column_spec.rb index bc2fa04ce64..7ef5556d8d7 100644 --- a/spec/rubocop/cop/migration/remove_column_spec.rb +++ b/spec/rubocop/cop/migration/remove_column_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/remove_column' -describe RuboCop::Cop::Migration::RemoveColumn do +RSpec.describe RuboCop::Cop::Migration::RemoveColumn, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb b/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb index 9de4c756f12..f70febb571d 100644 --- a/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb +++ b/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/remove_concurrent_index' -describe RuboCop::Cop::Migration::RemoveConcurrentIndex do +RSpec.describe RuboCop::Cop::Migration::RemoveConcurrentIndex, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/remove_index_spec.rb b/spec/rubocop/cop/migration/remove_index_spec.rb index d343d27484a..cc82306a0f5 100644 --- a/spec/rubocop/cop/migration/remove_index_spec.rb +++ b/spec/rubocop/cop/migration/remove_index_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/remove_index' -describe RuboCop::Cop::Migration::RemoveIndex do +RSpec.describe RuboCop::Cop::Migration::RemoveIndex, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb index b27a4cd4f80..013f2edc5e9 100644 --- a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb +++ b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/safer_boolean_column' -describe RuboCop::Cop::Migration::SaferBooleanColumn do +RSpec.describe RuboCop::Cop::Migration::SaferBooleanColumn, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/schedule_async_spec.rb b/spec/rubocop/cop/migration/schedule_async_spec.rb index 3453f1c51cc..a7246dfa73a 100644 --- a/spec/rubocop/cop/migration/schedule_async_spec.rb +++ b/spec/rubocop/cop/migration/schedule_async_spec.rb @@ -7,7 +7,7 @@ require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/migration/schedule_async' -describe RuboCop::Cop::Migration::ScheduleAsync do +RSpec.describe RuboCop::Cop::Migration::ScheduleAsync do include CopHelper let(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/timestamps_spec.rb b/spec/rubocop/cop/migration/timestamps_spec.rb index d03c75e7cfc..14b3cb36cf8 100644 --- a/spec/rubocop/cop/migration/timestamps_spec.rb +++ b/spec/rubocop/cop/migration/timestamps_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/timestamps' -describe RuboCop::Cop::Migration::Timestamps do +RSpec.describe RuboCop::Cop::Migration::Timestamps, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb index f72efaf2eb2..5d96e8048bf 100644 --- a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb +++ b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb @@ -7,7 +7,7 @@ require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/migration/update_column_in_batches' -describe RuboCop::Cop::Migration::UpdateColumnInBatches do +RSpec.describe RuboCop::Cop::Migration::UpdateColumnInBatches do let(:cop) { described_class.new } let(:tmp_rails_root) { Rails.root.join('tmp', 'rails_root') } let(:migration_code) do diff --git a/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb b/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb index 48570c1c8d8..11e4d784617 100644 --- a/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb +++ b/spec/rubocop/cop/migration/with_lock_retries_disallowed_method_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/with_lock_retries_disallowed_method' -describe RuboCop::Cop::Migration::WithLockRetriesDisallowedMethod do +RSpec.describe RuboCop::Cop::Migration::WithLockRetriesDisallowedMethod, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb index 75a1f939a9f..93b96f3a20e 100644 --- a/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb +++ b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb @@ -1,13 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' - +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/migration/with_lock_retries_with_change' -describe RuboCop::Cop::Migration::WithLockRetriesWithChange do +RSpec.describe RuboCop::Cop::Migration::WithLockRetriesWithChange, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/performance/ar_count_each_spec.rb b/spec/rubocop/cop/performance/ar_count_each_spec.rb index 534fa55dd45..33b667dd52f 100644 --- a/spec/rubocop/cop/performance/ar_count_each_spec.rb +++ b/spec/rubocop/cop/performance/ar_count_each_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true require 'fast_spec_helper' +require 'rubocop' require_relative '../../../../rubocop/cop/performance/ar_count_each.rb' -describe RuboCop::Cop::Performance::ARCountEach, type: :rubocop do +RSpec.describe RuboCop::Cop::Performance::ARCountEach, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb b/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb index da44004f947..972f3c52153 100644 --- a/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb +++ b/spec/rubocop/cop/performance/ar_exists_and_present_blank_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true require 'fast_spec_helper' +require 'rubocop' require_relative '../../../../rubocop/cop/performance/ar_exists_and_present_blank.rb' -describe RuboCop::Cop::Performance::ARExistsAndPresentBlank, type: :rubocop do +RSpec.describe RuboCop::Cop::Performance::ARExistsAndPresentBlank, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/performance/readlines_each_spec.rb b/spec/rubocop/cop/performance/readlines_each_spec.rb index e71aaaf3056..2f222f1dc00 100644 --- a/spec/rubocop/cop/performance/readlines_each_spec.rb +++ b/spec/rubocop/cop/performance/readlines_each_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true require 'fast_spec_helper' +require 'rubocop' require_relative '../../../../rubocop/cop/performance/readlines_each' -describe RuboCop::Cop::Performance::ReadlinesEach, type: :rubocop do +RSpec.describe RuboCop::Cop::Performance::ReadlinesEach, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } 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 4739f0e6c47..bed8d331209 100644 --- a/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb +++ b/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/prefer_class_methods_over_module' -describe RuboCop::Cop::PreferClassMethodsOverModule do +RSpec.describe RuboCop::Cop::PreferClassMethodsOverModule, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/project_path_helper_spec.rb b/spec/rubocop/cop/project_path_helper_spec.rb index 1b69030c798..0e5b0b10ae6 100644 --- a/spec/rubocop/cop/project_path_helper_spec.rb +++ b/spec/rubocop/cop/project_path_helper_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/project_path_helper' -describe RuboCop::Cop::ProjectPathHelper do +RSpec.describe RuboCop::Cop::ProjectPathHelper, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/put_group_routes_under_scope_spec.rb b/spec/rubocop/cop/put_group_routes_under_scope_spec.rb index c77412f91b4..2e577c9c578 100644 --- a/spec/rubocop/cop/put_group_routes_under_scope_spec.rb +++ b/spec/rubocop/cop/put_group_routes_under_scope_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require_relative '../../../rubocop/cop/put_group_routes_under_scope' -describe RuboCop::Cop::PutGroupRoutesUnderScope do +RSpec.describe RuboCop::Cop::PutGroupRoutesUnderScope, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb index 80ac4cc52e9..66e9044c453 100644 --- a/spec/rubocop/cop/put_project_routes_under_scope_spec.rb +++ b/spec/rubocop/cop/put_project_routes_under_scope_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require_relative '../../../rubocop/cop/put_project_routes_under_scope' -describe RuboCop::Cop::PutProjectRoutesUnderScope do +RSpec.describe RuboCop::Cop::PutProjectRoutesUnderScope, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb b/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb index 8ee720af9a5..484b5fad473 100644 --- a/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb +++ b/spec/rubocop/cop/qa/ambiguous_page_object_name_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/qa/ambiguous_page_object_name' -describe RuboCop::Cop::QA::AmbiguousPageObjectName do +RSpec.describe RuboCop::Cop::QA::AmbiguousPageObjectName, type: :rubocop do include CopHelper let(:source_file) { 'qa/page.rb' } diff --git a/spec/rubocop/cop/qa/element_with_pattern_spec.rb b/spec/rubocop/cop/qa/element_with_pattern_spec.rb index fee390caa9f..0e599701531 100644 --- a/spec/rubocop/cop/qa/element_with_pattern_spec.rb +++ b/spec/rubocop/cop/qa/element_with_pattern_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/qa/element_with_pattern' -describe RuboCop::Cop::QA::ElementWithPattern do +RSpec.describe RuboCop::Cop::QA::ElementWithPattern, type: :rubocop do include CopHelper let(:source_file) { 'qa/page.rb' } diff --git a/spec/rubocop/cop/rspec/any_instance_of_spec.rb b/spec/rubocop/cop/rspec/any_instance_of_spec.rb index b16f8ac189c..11c0f109850 100644 --- a/spec/rubocop/cop/rspec/any_instance_of_spec.rb +++ b/spec/rubocop/cop/rspec/any_instance_of_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require_relative '../../../../rubocop/cop/rspec/any_instance_of' -describe RuboCop::Cop::RSpec::AnyInstanceOf do +RSpec.describe RuboCop::Cop::RSpec::AnyInstanceOf, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/rspec/be_success_matcher_spec.rb b/spec/rubocop/cop/rspec/be_success_matcher_spec.rb index 12aa7d1643e..a16cd8b634f 100644 --- a/spec/rubocop/cop/rspec/be_success_matcher_spec.rb +++ b/spec/rubocop/cop/rspec/be_success_matcher_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require_relative '../../../../rubocop/cop/rspec/be_success_matcher' -describe RuboCop::Cop::RSpec::BeSuccessMatcher do +RSpec.describe RuboCop::Cop::RSpec::BeSuccessMatcher, type: :rubocop do include CopHelper let(:source_file) { 'spec/foo_spec.rb' } diff --git a/spec/rubocop/cop/rspec/env_assignment_spec.rb b/spec/rubocop/cop/rspec/env_assignment_spec.rb index 1c7cfb5c827..72ad584dd6f 100644 --- a/spec/rubocop/cop/rspec/env_assignment_spec.rb +++ b/spec/rubocop/cop/rspec/env_assignment_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/rspec/env_assignment' -describe RuboCop::Cop::RSpec::EnvAssignment do +RSpec.describe RuboCop::Cop::RSpec::EnvAssignment, type: :rubocop do include CopHelper offense_call_single_quotes_key = %(ENV['FOO'] = 'bar').freeze diff --git a/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb b/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb index 20013519db4..1bb93402a5b 100644 --- a/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb +++ b/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/rspec/factories_in_migration_specs' -describe RuboCop::Cop::RSpec::FactoriesInMigrationSpecs do +RSpec.describe RuboCop::Cop::RSpec::FactoriesInMigrationSpecs, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb b/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb index 4aa45e66ca7..f6040350dc0 100644 --- a/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb +++ b/spec/rubocop/cop/rspec/have_gitlab_http_status_spec.rb @@ -8,7 +8,7 @@ require 'rubocop/rspec/support' require_relative '../../../../rubocop/cop/rspec/have_gitlab_http_status' -describe RuboCop::Cop::RSpec::HaveGitlabHttpStatus do +RSpec.describe RuboCop::Cop::RSpec::HaveGitlabHttpStatus do include CopHelper using RSpec::Parameterized::TableSyntax diff --git a/spec/rubocop/cop/rspec/modify_sidekiq_middleware_spec.rb b/spec/rubocop/cop/rspec/modify_sidekiq_middleware_spec.rb index d3d323b6643..ca47bba4264 100644 --- a/spec/rubocop/cop/rspec/modify_sidekiq_middleware_spec.rb +++ b/spec/rubocop/cop/rspec/modify_sidekiq_middleware_spec.rb @@ -4,9 +4,8 @@ require 'fast_spec_helper' require 'rubocop' require_relative '../../../../rubocop/cop/rspec/modify_sidekiq_middleware' -describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware, type: :rubocop do +RSpec.describe RuboCop::Cop::RSpec::ModifySidekiqMiddleware, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb b/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb index ee6b6d39cb4..92a76bde243 100644 --- a/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb +++ b/spec/rubocop/cop/rspec/top_level_describe_path_spec.rb @@ -1,14 +1,10 @@ # frozen_string_literal: true require 'fast_spec_helper' - require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/rspec/top_level_describe_path' -describe RuboCop::Cop::RSpec::TopLevelDescribePath do - include RuboCop::RSpec::ExpectOffense +RSpec.describe RuboCop::Cop::RSpec::TopLevelDescribePath, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb b/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb index 7bd50866577..938ddc7fb6a 100644 --- a/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb +++ b/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' @@ -9,7 +9,7 @@ require_relative '../../../rubocop/cop/ruby_interpolation_in_translation' # Disabling interpolation check as we deliberately want to have #{} in strings. # rubocop:disable Lint/InterpolationCheck -describe RuboCop::Cop::RubyInterpolationInTranslation do +RSpec.describe RuboCop::Cop::RubyInterpolationInTranslation, type: :rubocop do subject(:cop) { described_class.new } it 'does not add an offence for a regular messages' do diff --git a/spec/rubocop/cop/safe_params_spec.rb b/spec/rubocop/cop/safe_params_spec.rb index 4f02b8e9008..c4f683a41bf 100644 --- a/spec/rubocop/cop/safe_params_spec.rb +++ b/spec/rubocop/cop/safe_params_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/safe_params' -describe RuboCop::Cop::SafeParams do +RSpec.describe RuboCop::Cop::SafeParams, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb index 61603d0100e..48964ab76e0 100644 --- a/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb +++ b/spec/rubocop/cop/scalability/bulk_perform_with_context_spec.rb @@ -4,9 +4,8 @@ require 'fast_spec_helper' require 'rubocop' require_relative '../../../../rubocop/cop/scalability/bulk_perform_with_context' -describe RuboCop::Cop::Scalability::BulkPerformWithContext, type: :rubocop do +RSpec.describe RuboCop::Cop::Scalability::BulkPerformWithContext, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb index e917d33b1e5..4b4ee7258f1 100644 --- a/spec/rubocop/cop/scalability/cron_worker_context_spec.rb +++ b/spec/rubocop/cop/scalability/cron_worker_context_spec.rb @@ -4,9 +4,8 @@ require 'fast_spec_helper' require 'rubocop' require_relative '../../../../rubocop/cop/scalability/cron_worker_context' -describe RuboCop::Cop::Scalability::CronWorkerContext, type: :rubocop do +RSpec.describe RuboCop::Cop::Scalability::CronWorkerContext, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/scalability/file_uploads_spec.rb b/spec/rubocop/cop/scalability/file_uploads_spec.rb index b0be9ac2b51..ed826728681 100644 --- a/spec/rubocop/cop/scalability/file_uploads_spec.rb +++ b/spec/rubocop/cop/scalability/file_uploads_spec.rb @@ -4,9 +4,8 @@ require 'fast_spec_helper' require 'rubocop' require_relative '../../../../rubocop/cop/scalability/file_uploads' -describe RuboCop::Cop::Scalability::FileUploads, type: :rubocop do +RSpec.describe RuboCop::Cop::Scalability::FileUploads, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb index 73cacc984e9..9197cc954f5 100644 --- a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb +++ b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb @@ -4,9 +4,8 @@ require 'fast_spec_helper' require 'rubocop' require_relative '../../../../rubocop/cop/scalability/idempotent_worker' -describe RuboCop::Cop::Scalability::IdempotentWorker, type: :rubocop do +RSpec.describe RuboCop::Cop::Scalability::IdempotentWorker, type: :rubocop do include CopHelper - include ExpectOffense subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/sidekiq_options_queue_spec.rb b/spec/rubocop/cop/sidekiq_options_queue_spec.rb index c10fd7bd32b..e76265d426c 100644 --- a/spec/rubocop/cop/sidekiq_options_queue_spec.rb +++ b/spec/rubocop/cop/sidekiq_options_queue_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/sidekiq_options_queue' -describe RuboCop::Cop::SidekiqOptionsQueue do +RSpec.describe RuboCop::Cop::SidekiqOptionsQueue, type: :rubocop do include CopHelper subject(:cop) { described_class.new } diff --git a/spec/rubocop/cop/static_translation_definition_spec.rb b/spec/rubocop/cop/static_translation_definition_spec.rb index b85f9da9b4e..b6c9f6a25df 100644 --- a/spec/rubocop/cop/static_translation_definition_spec.rb +++ b/spec/rubocop/cop/static_translation_definition_spec.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' +require 'rspec-parameterized' require_relative '../../../rubocop/cop/static_translation_definition' -describe RuboCop::Cop::StaticTranslationDefinition do +RSpec.describe RuboCop::Cop::StaticTranslationDefinition, type: :rubocop do include CopHelper using RSpec::Parameterized::TableSyntax diff --git a/spec/rubocop/migration_helpers_spec.rb b/spec/rubocop/migration_helpers_spec.rb index 73ced8c58da..f0be21c9d70 100644 --- a/spec/rubocop/migration_helpers_spec.rb +++ b/spec/rubocop/migration_helpers_spec.rb @@ -6,7 +6,7 @@ require 'rspec-parameterized' require_relative '../../rubocop/migration_helpers' -describe RuboCop::MigrationHelpers do +RSpec.describe RuboCop::MigrationHelpers do using RSpec::Parameterized::TableSyntax subject(:fake_cop) { Class.new { include RuboCop::MigrationHelpers }.new } diff --git a/spec/rubocop/qa_helpers_spec.rb b/spec/rubocop/qa_helpers_spec.rb index 26e4c1ca6f0..786b9c78952 100644 --- a/spec/rubocop/qa_helpers_spec.rb +++ b/spec/rubocop/qa_helpers_spec.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -require 'spec_helper' +require 'fast_spec_helper' require 'rubocop' +require 'parser/current' require_relative '../../rubocop/qa_helpers' -describe RuboCop::QAHelpers do +RSpec.describe RuboCop::QAHelpers, type: :rubocop do def parse_source(source, path = 'foo.rb') buffer = Parser::Source::Buffer.new(path) buffer.source = source @@ -23,13 +24,13 @@ describe RuboCop::QAHelpers do describe '#in_qa_file?' do it 'returns true for a node in the qa/ directory' do - node = parse_source('10', Rails.root.join('qa', 'qa', 'page', 'dashboard', 'groups.rb')) + node = parse_source('10', rails_root_join('qa', 'qa', 'page', 'dashboard', 'groups.rb')) expect(cop.in_qa_file?(node)).to eq(true) end it 'returns false for a node outside the qa/ directory' do - node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb')) + node = parse_source('10', rails_root_join('app', 'foo', 'foo.rb')) expect(cop.in_qa_file?(node)).to eq(false) end |