blob: cf8d0d1b66f14a8883de4f33799356699c4c9d83 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../../rubocop/cop/sidekiq_load_balancing/worker_data_consistency'
RSpec.describe RuboCop::Cop::SidekiqLoadBalancing::WorkerDataConsistency do
subject(:cop) { described_class.new }
before do
allow(cop)
.to receive(:in_worker?)
.and_return(true)
end
it 'adds an offense when not defining data_consistency' do
expect_offense(<<~CODE)
class SomeWorker
^^^^^^^^^^^^^^^^ Should define data_consistency expectation.[...]
include ApplicationWorker
queue_namespace :pipeline_hooks
feature_category :continuous_integration
urgency :high
end
CODE
end
it 'adds no offense when defining data_consistency' do
expect_no_offenses(<<~CODE)
class SomeWorker
include ApplicationWorker
queue_namespace :pipeline_hooks
feature_category :continuous_integration
data_consistency :delayed
urgency :high
end
CODE
end
it 'adds no offense when worker is not an ApplicationWorker' do
expect_no_offenses(<<~CODE)
class SomeWorker
queue_namespace :pipeline_hooks
feature_category :continuous_integration
urgency :high
end
CODE
end
end
|