diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/rubocop/cop/destroy_all_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/rubocop/cop/destroy_all_spec.rb')
-rw-r--r-- | spec/rubocop/cop/destroy_all_spec.rb | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/spec/rubocop/cop/destroy_all_spec.rb b/spec/rubocop/cop/destroy_all_spec.rb index df664724a91..f6850a00238 100644 --- a/spec/rubocop/cop/destroy_all_spec.rb +++ b/spec/rubocop/cop/destroy_all_spec.rb @@ -2,44 +2,41 @@ require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/destroy_all' RSpec.describe RuboCop::Cop::DestroyAll do - include CopHelper - subject(:cop) { described_class.new } it 'flags the use of destroy_all with a send receiver' do - inspect_source('foo.destroy_all # rubocop: disable Cop/DestroyAll') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~CODE) + foo.destroy_all # rubocop: disable Cop/DestroyAll + ^^^^^^^^^^^^^^^ Use `delete_all` instead of `destroy_all`. [...] + CODE end it 'flags the use of destroy_all with a constant receiver' do - inspect_source('User.destroy_all # rubocop: disable Cop/DestroyAll') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~CODE) + User.destroy_all # rubocop: disable Cop/DestroyAll + ^^^^^^^^^^^^^^^^ Use `delete_all` instead of `destroy_all`. [...] + CODE end it 'flags the use of destroy_all when passing arguments' do - inspect_source('User.destroy_all([])') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~CODE) + User.destroy_all([]) + ^^^^^^^^^^^^^^^^^^^^ Use `delete_all` instead of `destroy_all`. [...] + CODE end it 'flags the use of destroy_all with a local variable receiver' do - inspect_source(<<~RUBY) - users = User.all - users.destroy_all # rubocop: disable Cop/DestroyAll - RUBY - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~CODE) + users = User.all + users.destroy_all # rubocop: disable Cop/DestroyAll + ^^^^^^^^^^^^^^^^^ Use `delete_all` instead of `destroy_all`. [...] + CODE end it 'does not flag the use of delete_all' do - inspect_source('foo.delete_all') - - expect(cop.offenses).to be_empty + expect_no_offenses('foo.delete_all') end end |