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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-11 12:09:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-11 12:09:58 +0300
commita350f877c4246fee981690388239d1e19e17202a (patch)
treefc75efe26a34c732ab85b1dc6cf09fcab558e3f8 /spec/rubocop
parent7adadf7e5b83c46f7e83051146624719e9b6bf0d (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop')
-rw-r--r--spec/rubocop/cop/rspec/have_enqueued_sidekiq_job_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/rubocop/cop/rspec/have_enqueued_sidekiq_job_spec.rb b/spec/rubocop/cop/rspec/have_enqueued_sidekiq_job_spec.rb
new file mode 100644
index 00000000000..506cdb6e4e8
--- /dev/null
+++ b/spec/rubocop/cop/rspec/have_enqueued_sidekiq_job_spec.rb
@@ -0,0 +1,51 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require_relative '../../../../rubocop/cop/rspec/have_enqueued_sidekiq_job'
+
+RSpec.describe RuboCop::Cop::RSpec::HaveEnqueuedSidekiqJob do
+ let(:source_file) { 'spec/foo_spec.rb' }
+
+ subject(:cop) { described_class.new }
+
+ shared_examples 'cop' do |good:, bad:|
+ context "using #{bad} call" do
+ it 'registers an offense', :aggregate_failures do
+ expect_offense(<<~CODE, node: bad)
+ %{node}
+ ^{node} Do not use `receive(:perform_async)` to check a job has been enqueued, use `have_enqueued_sidekiq_job` instead.
+ CODE
+ end
+ end
+
+ context "using #{good} call" do
+ it 'does not register an offense' do
+ expect_no_offenses(good)
+ end
+ end
+ end
+
+ it_behaves_like 'cop',
+ bad: 'expect(Worker).to receive(:perform_async)',
+ good: 'expect(Worker).to have_enqueued_sidekiq_job'
+
+ include_examples 'cop',
+ bad: 'expect(Worker).not_to receive(:perform_async)',
+ good: 'expect(Worker).not_to have_enqueued_sidekiq_job'
+
+ include_examples 'cop',
+ bad: 'expect(Worker).to_not receive(:perform_async)',
+ good: 'expect(Worker).to_not have_enqueued_sidekiq_job'
+
+ include_examples 'cop',
+ bad: 'expect(Worker).to receive(:perform_async).with(1)',
+ good: 'expect(Worker).to have_enqueued_sidekiq_job(1)'
+
+ include_examples 'cop',
+ bad: 'expect(Worker).to receive(:perform_async).with(1).once',
+ good: 'expect(Worker).to have_enqueued_sidekiq_job(1)'
+
+ include_examples 'cop',
+ bad: 'expect(any_variable_or_method).to receive(:perform_async).with(1)',
+ good: 'expect(any_variable_or_method).to have_enqueued_sidekiq_job(1)'
+end