diff --git a/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb b/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb index e14ef30bc..20936390f 100644 --- a/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb +++ b/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb @@ -1,10 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::RSpec::FactoryBot::AttributeDefinedStatically do - def inspected_source_filename - 'spec/factories.rb' - end - it 'registers an offense for offending code' do expect_offense(<<-RUBY) FactoryBot.define do diff --git a/spec/rubocop/cop/rspec/factory_bot/factory_class_name_spec.rb b/spec/rubocop/cop/rspec/factory_bot/factory_class_name_spec.rb index b2d1705e6..31fb5d217 100644 --- a/spec/rubocop/cop/rspec/factory_bot/factory_class_name_spec.rb +++ b/spec/rubocop/cop/rspec/factory_bot/factory_class_name_spec.rb @@ -1,10 +1,6 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::RSpec::FactoryBot::FactoryClassName do - def inspected_source_filename - 'spec/factories.rb' - end - context 'when passing block' do it 'flags passing a class' do expect_offense(<<~RUBY) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fc00e62a5..8a0551605 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -33,7 +33,7 @@ module SpecHelper # We should take their advice! config.raise_on_warning = true - config.include(ExpectOffense) + config.include(RuboCop::RSpec::ExpectOffense) config.include_context 'with default RSpec/Language config', :config config.include_context 'smoke test', type: :cop_spec diff --git a/spec/support/expect_offense.rb b/spec/support/expect_offense.rb deleted file mode 100644 index 957c728ec..000000000 --- a/spec/support/expect_offense.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# rubocop-rspec gem extension of RuboCop's ExpectOffense module. -# -# This mixin is the same as rubocop's ExpectOffense except the default -# filename ends with `_spec.rb` -# -# Cops assigned to departments may focus on different files, so it is -# possible to override the inspected file name. -module ExpectOffense - include RuboCop::RSpec::ExpectOffense - - DEFAULT_FILENAME = 'example_spec.rb' - - def expect_offense(source, filename = inspected_source_filename, - *args, **kwargs) - super - end - - def expect_no_offenses(source, filename = inspected_source_filename) - super - end - - def inspected_source_filename - DEFAULT_FILENAME - end -end