diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-12 00:09:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-12 00:09:40 +0300 |
commit | 3f45eb27e9586ad87682c2d125770e119a7e9fe0 (patch) | |
tree | 533c2906ecf49c1403a2c21211241f21768e139a /spec/rubocop | |
parent | 636eb69592af287dd76876e6fc3c898ad1af33f6 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r-- | spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb b/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb new file mode 100644 index 00000000000..11d63d8e0ee --- /dev/null +++ b/spec/rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'spec_helper' +require 'rubocop' +require 'rubocop/rspec/support' +require_relative '../../../rubocop/cop/avoid_keyword_arguments_in_sidekiq_workers' + +describe RuboCop::Cop::AvoidKeywordArgumentsInSidekiqWorkers do + include CopHelper + + subject(:cop) { described_class.new } + + it 'flags violation for keyword arguments usage in perform method signature' do + expect_offense(<<~RUBY) + def perform(id:) + ^^^^^^^^^^^^^^^^ Do not use keyword arguments in Sidekiq workers. For details, check https://github.com/mperham/sidekiq/issues/2372 + end + RUBY + end + + it 'flags violation for optional keyword arguments usage in perform method signature' do + expect_offense(<<~RUBY) + def perform(id: nil) + ^^^^^^^^^^^^^^^^^^^^ Do not use keyword arguments in Sidekiq workers. For details, check https://github.com/mperham/sidekiq/issues/2372 + end + RUBY + end + + it 'does not flag a violation for standard optional arguments usage in perform method signature' do + expect_no_offenses(<<~RUBY) + def perform(id = nil) + end + RUBY + end + + it 'does not flag a violation for keyword arguments usage in non-perform method signatures' do + expect_no_offenses(<<~RUBY) + def helper(id:) + end + RUBY + end + + it 'does not flag a violation for optional keyword arguments usage in non-perform method signatures' do + expect_no_offenses(<<~RUBY) + def helper(id: nil) + end + RUBY + end +end |