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/default_scope_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/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 |