Skip to content

Commit

Permalink
Use RuboCop RSpec 2.23
Browse files Browse the repository at this point in the history
This commit uses RuboCop RSpec 2.23 and suppresses new `RSpec/ReceiveMessages` offenses.
https://github.com/rubocop/rubocop-rspec/releases/tag/v2.23.0
  • Loading branch information
koic committed Jul 30, 2023
1 parent 28e1456 commit 59e940b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.7'
gem 'rubocop-performance', '~> 1.18.0'
gem 'rubocop-rake', '~> 0.6.0'
gem 'rubocop-rspec', '~> 2.22.0'
gem 'rubocop-rspec', '~> 2.23.0'
# Workaround for cc-test-reporter with SimpleCov 0.18.
# Stop upgrading SimpleCov until the following issue will be resolved.
# https://github.com/codeclimate/test-reporter/issues/418
Expand Down
6 changes: 2 additions & 4 deletions spec/rubocop/cop/cop_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def autocorrect(node); end

context 'when offense was corrected' do
before do
allow(cop).to receive(:autocorrect?).and_return(true)
allow(cop).to receive(:autocorrect).and_return(lambda do |corrector|
allow(cop).to receive_messages(autocorrect?: true, autocorrect: lambda do |corrector|
corrector.insert_before(location, 'hi!')
end)
end
Expand All @@ -199,8 +198,7 @@ def autocorrect(node); end

context 'when offense was not corrected because of an error' do
before do
allow(cop).to receive(:autocorrect?).and_return(true)
allow(cop).to receive(:autocorrect).and_return(false)
allow(cop).to receive_messages(autocorrect?: true, autocorrect: false)
end

it 'is set to false' do
Expand Down
22 changes: 11 additions & 11 deletions spec/rubocop/target_finder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -554,24 +554,24 @@
allow(config).to receive(:file_to_include?) do |file|
File.basename(file) == 'file'
end
allow(config)
.to receive(:for_all_cops).and_return('Exclude' => [],
'Include' => [],
'RubyInterpreters' => [])
allow(config).to receive(:[]).and_return([])
allow(config).to receive(:file_to_exclude?).and_return(false)
allow(config).to receive_messages(
for_all_cops: { 'Exclude' => [], 'Include' => [], 'RubyInterpreters' => [] },
:[] => [],
file_to_exclude?: false
)

allow(config_store).to receive(:for).and_return(config)

expect(found_basenames.include?('file')).to be(true)
end

it 'does not pick files specified to be excluded in config' do
config = instance_double(RuboCop::Config).as_null_object
allow(config)
.to receive(:for_all_cops).and_return('Exclude' => [],
'Include' => [],
'RubyInterpreters' => [])
allow(config).to receive(:file_to_include?).and_return(false)
allow(config).to receive_messages(
for_all_cops: { 'Exclude' => [], 'Include' => [], 'RubyInterpreters' => [] },
file_to_include?: false
)

allow(config).to receive(:file_to_exclude?) do |file|
File.basename(file) == 'ruby2.rb'
end
Expand Down

0 comments on commit 59e940b

Please sign in to comment.