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:
Diffstat (limited to 'spec/rubocop/cop/scalability/idempotent_worker_spec.rb')
-rw-r--r--spec/rubocop/cop/scalability/idempotent_worker_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/rubocop/cop/scalability/idempotent_worker_spec.rb b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb
new file mode 100644
index 00000000000..7abd602f8bc
--- /dev/null
+++ b/spec/rubocop/cop/scalability/idempotent_worker_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'fast_spec_helper'
+require 'rubocop'
+require_relative '../../../support/helpers/expect_offense'
+require_relative '../../../../rubocop/cop/scalability/idempotent_worker'
+
+describe RuboCop::Cop::Scalability::IdempotentWorker do
+ include CopHelper
+ include ExpectOffense
+
+ subject(:cop) { described_class.new }
+
+ before do
+ allow(cop)
+ .to receive(:in_worker?)
+ .and_return(true)
+ end
+
+ it 'adds an offense when not defining idempotent method' do
+ inspect_source(<<~CODE.strip_indent)
+ class SomeWorker
+ end
+ CODE
+
+ expect(cop.offenses.size).to eq(1)
+ end
+
+ it 'adds an offense when not defining idempotent method' do
+ inspect_source(<<~CODE.strip_indent)
+ class SomeWorker
+ idempotent!
+ end
+ CODE
+
+ expect(cop.offenses.size).to be_zero
+ end
+end