diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-26 21:09:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-26 21:09:30 +0300 |
commit | 25eb713a7fdb787a67d74a88a89433839aab5642 (patch) | |
tree | 43cfe6c45530aedfd7f96d6c6d0e5857ce1d5ee3 /spec/rubocop/cop/default_scope_spec.rb | |
parent | ff89c3c372cd3b317915fb21940f9c8c065d94c0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/cop/default_scope_spec.rb')
-rw-r--r-- | spec/rubocop/cop/default_scope_spec.rb | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/spec/rubocop/cop/default_scope_spec.rb b/spec/rubocop/cop/default_scope_spec.rb index fee1895603c..506843e030e 100644 --- a/spec/rubocop/cop/default_scope_spec.rb +++ b/spec/rubocop/cop/default_scope_spec.rb @@ -2,47 +2,44 @@ require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' require_relative '../../../rubocop/cop/default_scope' RSpec.describe RuboCop::Cop::DefaultScope do - include CopHelper - subject(:cop) { described_class.new } it 'does not flag the use of default_scope with a send receiver' do - inspect_source('foo.default_scope') - - expect(cop.offenses.size).to eq(0) + expect_no_offenses('foo.default_scope') end it 'flags the use of default_scope with a constant receiver' do - inspect_source('User.default_scope') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~SOURCE) + User.default_scope + ^^^^^^^^^^^^^^^^^^ Do not use `default_scope`, [...] + SOURCE end it 'flags the use of default_scope with a nil receiver' do - inspect_source('class Foo ; default_scope ; end') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~SOURCE) + class Foo ; default_scope ; end + ^^^^^^^^^^^^^ Do not use `default_scope`, [...] + SOURCE end it 'flags the use of default_scope when passing arguments' do - inspect_source('class Foo ; default_scope(:foo) ; end') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~SOURCE) + class Foo ; default_scope(:foo) ; end + ^^^^^^^^^^^^^^^^^^^ Do not use `default_scope`, [...] + SOURCE end it 'flags the use of default_scope when passing a block' do - inspect_source('class Foo ; default_scope { :foo } ; end') - - expect(cop.offenses.size).to eq(1) + expect_offense(<<~SOURCE) + class Foo ; default_scope { :foo } ; end + ^^^^^^^^^^^^^ Do not use `default_scope`, [...] + SOURCE end it 'ignores the use of default_scope with a local variable receiver' do - inspect_source('users = User.all ; users.default_scope') - - expect(cop.offenses.size).to eq(0) + expect_no_offenses('users = User.all ; users.default_scope') end end |