Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/destroy_all_spec.rb')
-rw-r--r--spec/rubocop/cop/destroy_all_spec.rb39
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