diff options
author | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2021-01-20 22:34:23 +0300 |
commit | 6438df3a1e0fb944485cebf07976160184697d72 (patch) | |
tree | 00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/rubocop/cop/lint/last_keyword_argument_spec.rb | |
parent | 42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff) |
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/rubocop/cop/lint/last_keyword_argument_spec.rb')
-rw-r--r-- | spec/rubocop/cop/lint/last_keyword_argument_spec.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/rubocop/cop/lint/last_keyword_argument_spec.rb b/spec/rubocop/cop/lint/last_keyword_argument_spec.rb index 5822bf74e8d..826c681a880 100644 --- a/spec/rubocop/cop/lint/last_keyword_argument_spec.rb +++ b/spec/rubocop/cop/lint/last_keyword_argument_spec.rb @@ -4,7 +4,7 @@ require 'fast_spec_helper' require 'rubocop' require_relative '../../../../rubocop/cop/lint/last_keyword_argument' -RSpec.describe RuboCop::Cop::Lint::LastKeywordArgument, type: :rubocop do +RSpec.describe RuboCop::Cop::Lint::LastKeywordArgument do include CopHelper subject(:cop) { described_class.new } @@ -38,6 +38,8 @@ RSpec.describe RuboCop::Cop::Lint::LastKeywordArgument, type: :rubocop do - | DEPRECATION WARNING: /Users/tkuah/code/ee-gdk/gitlab/create_service.rb:1: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /Users/tkuah/code/ee-gdk/gitlab/user.rb:17: warning: The called method `call' is defined here + - | + DEPRECATION WARNING: /Users/tkuah/code/ee-gdk/gitlab/other_warning_type.rb:1: warning: Some other warning type YAML end @@ -62,7 +64,7 @@ RSpec.describe RuboCop::Cop::Lint::LastKeywordArgument, type: :rubocop do allow(File).to receive(:read).and_return(create_spec_yaml, projects_spec_yaml) end - it 'registers an offense' do + it 'registers an offense for last keyword warning' do expect_offense(<<~SOURCE, 'create_service.rb') users.call(params) ^^^^^^ Using the last argument as keyword parameters is deprecated @@ -73,6 +75,12 @@ RSpec.describe RuboCop::Cop::Lint::LastKeywordArgument, type: :rubocop do SOURCE end + it 'does not register an offense for other warning types' do + expect_no_offenses(<<~SOURCE, 'other_warning_type.rb') + users.call(params) + SOURCE + end + it 'registers an offense for the new method call' do expect_offense(<<~SOURCE, 'projects_spec.rb') Project.new(params) @@ -95,6 +103,23 @@ RSpec.describe RuboCop::Cop::Lint::LastKeywordArgument, type: :rubocop do SOURCE end + it 'registers an offense on the last non-block argument' do + expect_offense(<<~SOURCE, 'create_service.rb') + users.call(id, params, &block) + ^^^^^^ Using the last argument as keyword parameters is deprecated + SOURCE + + expect_correction(<<~SOURCE) + users.call(id, **params, &block) + SOURCE + end + + it 'does not register an offense if the only argument is a block argument' do + expect_no_offenses(<<~SOURCE, 'create_service.rb') + users.call(&block) + SOURCE + end + it 'registers an offense and corrects by converting splat to double splat' do expect_offense(<<~SOURCE, 'create_service.rb') users.call(id, *params) |