Skip to content

Commit

Permalink
Merge pull request #924 from rubocop-hq/fix-leaky-constant-declarations
Browse files Browse the repository at this point in the history
Fix leaky constant declaration in specs
  • Loading branch information
bquorning committed Jun 7, 2020
2 parents 97e8ebb + f6ac99e commit 8eb550e
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions spec/rubocop/cop/rspec/cop_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::Cop do
subject(:cop) { fake_cop.new(config) }
subject(:cop) { RuboCop::RSpec::FakeCop.new(config) }

let(:config) do
rubocop_config =
Expand All @@ -19,21 +19,17 @@
RuboCop::Config.new(rubocop_config, 'fake_cop_config.yml')
end

let(:fake_cop) do
# rubocop:disable Style/ClassAndModuleChildren
# rubocop:disable RSpec/LeakyConstantDeclaration
class RuboCop::RSpec::FakeCop < described_class
def on_send(node)
add_offense(node, message: 'I flag everything')
end
end
# rubocop:enable Style/ClassAndModuleChildren
# rubocop:enable RSpec/LeakyConstantDeclaration
RuboCop::RSpec::FakeCop
end

let(:rspec_patterns) { ['_spec.rb$', '(?:^|/)spec/'] }

before do
stub_const('RuboCop::RSpec::FakeCop',
Class.new(described_class) do
def on_send(node)
add_offense(node, message: 'I flag everything')
end
end)
end

context 'when the source path ends with `_spec.rb`' do
it 'registers an offense' do
expect_offense(<<-RUBY, 'foo_spec.rb')
Expand Down

0 comments on commit 8eb550e

Please sign in to comment.