rspec-sidekiq 3.1.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +24 -0
- data/LICENSE +12 -0
- data/README.md +198 -81
- data/lib/rspec/sidekiq/batch.rb +20 -2
- data/lib/rspec/sidekiq/configuration.rb +13 -2
- data/lib/rspec/sidekiq/matchers/base.rb +256 -0
- data/lib/rspec/sidekiq/matchers/be_delayed.rb +17 -3
- data/lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb +87 -0
- data/lib/rspec/sidekiq/matchers/have_enqueued_sidekiq_job.rb +25 -0
- data/lib/rspec/sidekiq/matchers.rb +13 -8
- data/lib/rspec/sidekiq/sidekiq.rb +1 -1
- data/lib/rspec/sidekiq/version.rb +1 -1
- metadata +89 -39
- data/.gitattributes +0 -22
- data/.gitignore +0 -2
- data/.rspec +0 -4
- data/.simplecov +0 -5
- data/Gemfile +0 -9
- data/lib/rspec/sidekiq/matchers/have_enqueued_job.rb +0 -183
- data/rspec-sidekiq.gemspec +0 -39
- data/spec/rspec/sidekiq/batch_spec.rb +0 -83
- data/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb +0 -40
- data/spec/rspec/sidekiq/matchers/be_delayed_spec.rb +0 -238
- data/spec/rspec/sidekiq/matchers/be_expired_in_spec.rb +0 -57
- data/spec/rspec/sidekiq/matchers/be_processed_in_spec.rb +0 -114
- data/spec/rspec/sidekiq/matchers/be_retryable_spec.rb +0 -129
- data/spec/rspec/sidekiq/matchers/be_unique_spec.rb +0 -115
- data/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +0 -229
- data/spec/rspec/sidekiq/matchers/save_backtrace_spec.rb +0 -136
- data/spec/rspec/sidekiq/sidekiq_spec.rb +0 -15
- data/spec/spec_helper.rb +0 -29
- data/spec/support/factories.rb +0 -33
- data/spec/support/init.rb +0 -6
- data/spec/support/test_action_mailer.rb +0 -6
- data/spec/support/test_job.rb +0 -6
- data/spec/support/test_resource.rb +0 -10
- data/spec/support/test_worker.rb +0 -8
- data/spec/support/test_worker_alternative.rb +0 -8
@@ -1,114 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe RSpec::Sidekiq::Matchers::BeProcessedIn do
|
4
|
-
let(:symbol_subject) { RSpec::Sidekiq::Matchers::BeProcessedIn.new :a_queue }
|
5
|
-
let(:symbol_worker) { create_worker queue: :a_queue }
|
6
|
-
let(:string_subject) { RSpec::Sidekiq::Matchers::BeProcessedIn.new 'a_queue' }
|
7
|
-
let(:string_worker) { create_worker queue: 'a_queue' }
|
8
|
-
let(:active_job) { create_active_job :mailers }
|
9
|
-
|
10
|
-
before(:each) do
|
11
|
-
symbol_subject.matches? symbol_worker
|
12
|
-
string_subject.matches? string_worker
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'expected usage' do
|
16
|
-
it 'matches' do
|
17
|
-
expect(symbol_worker).to be_processed_in :a_queue
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'matches on an ActiveJob' do
|
21
|
-
expect(active_job).to be_processed_in :mailers
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#be_processed_in' do
|
26
|
-
it 'returns instance' do
|
27
|
-
expect(be_processed_in :a_queue).to be_a RSpec::Sidekiq::Matchers::BeProcessedIn
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#description' do
|
32
|
-
context 'when expected is a symbol' do
|
33
|
-
it 'returns description' do
|
34
|
-
expect(symbol_subject.description).to eq "be processed in the \"a_queue\" queue"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when expected is a string' do
|
39
|
-
it 'returns description' do
|
40
|
-
expect(string_subject.description).to eq "be processed in the \"a_queue\" queue"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#failure_message' do
|
46
|
-
context 'when expected is a symbol' do
|
47
|
-
it 'returns message' do
|
48
|
-
expect(symbol_subject.failure_message).to eq "expected #{symbol_worker} to be processed in the \"a_queue\" queue but got \"a_queue\""
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when expected is a string' do
|
53
|
-
it 'returns message' do
|
54
|
-
expect(string_subject.failure_message).to eq "expected #{string_worker} to be processed in the \"a_queue\" queue but got \"a_queue\""
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#matches?' do
|
60
|
-
context 'when condition matches' do
|
61
|
-
context 'when expected is a symbol' do
|
62
|
-
it 'returns true' do
|
63
|
-
expect(symbol_subject.matches? symbol_worker).to be true
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when expected is a symbol and actual is string' do
|
68
|
-
it 'returns true' do
|
69
|
-
expect(symbol_subject.matches? string_worker).to be true
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'when expected is a string' do
|
74
|
-
it 'returns true' do
|
75
|
-
expect(string_subject.matches? string_worker).to be true
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
context 'when expected is a string and actual is symbol' do
|
80
|
-
it 'returns true' do
|
81
|
-
expect(string_subject.matches? symbol_worker).to be true
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context 'when condition does not match' do
|
87
|
-
context 'when expected is a symbol' do
|
88
|
-
it 'returns false' do
|
89
|
-
expect(symbol_subject.matches? create_worker queue: :another_queue).to be false
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
context 'when expected is a string' do
|
94
|
-
it 'returns false' do
|
95
|
-
expect(string_subject.matches? create_worker queue: 'another_queue').to be false
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#failure_message_when_negated' do
|
102
|
-
context 'when expected is a symbol' do
|
103
|
-
it 'returns message' do
|
104
|
-
expect(symbol_subject.failure_message_when_negated).to eq "expected #{symbol_worker} to not be processed in the \"a_queue\" queue"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context 'when expected is a string' do
|
109
|
-
it 'returns message' do
|
110
|
-
expect(string_subject.failure_message_when_negated).to eq "expected #{string_worker} to not be processed in the \"a_queue\" queue"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe RSpec::Sidekiq::Matchers::BeRetryable do
|
4
|
-
let(:specific_subject) { RSpec::Sidekiq::Matchers::BeRetryable.new 2 }
|
5
|
-
let(:specific_worker) { create_worker retry: 2 }
|
6
|
-
let(:default_subject) { RSpec::Sidekiq::Matchers::BeRetryable.new true }
|
7
|
-
let(:default_worker) { create_worker retry: true }
|
8
|
-
let(:negative_subject) { RSpec::Sidekiq::Matchers::BeRetryable.new false }
|
9
|
-
let(:negative_worker) { create_worker retry: false }
|
10
|
-
before(:each) do
|
11
|
-
specific_subject.matches? specific_worker
|
12
|
-
default_subject.matches? default_worker
|
13
|
-
negative_subject.matches? negative_worker
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'expected usage' do
|
17
|
-
it 'matches' do
|
18
|
-
expect(default_worker).to be_retryable true
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#be_retryable' do
|
23
|
-
it 'returns instance' do
|
24
|
-
expect(be_retryable true).to be_a RSpec::Sidekiq::Matchers::BeRetryable
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#description' do
|
29
|
-
context 'when expected is a number' do
|
30
|
-
it 'returns description' do
|
31
|
-
expect(specific_subject.description).to eq 'retry 2 times'
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when expected is true' do
|
36
|
-
it 'returns description' do
|
37
|
-
expect(default_subject.description).to eq 'retry the default number of times'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'when expected is false' do
|
42
|
-
it 'returns description' do
|
43
|
-
expect(negative_subject.description).to eq 'not retry'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#failure_message' do
|
49
|
-
context 'when expected is a number' do
|
50
|
-
it 'returns message' do
|
51
|
-
expect(specific_subject.failure_message).to eq "expected #{specific_worker} to retry 2 times but got 2"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'when expected is true' do
|
56
|
-
it 'returns message' do
|
57
|
-
expect(default_subject.failure_message).to eq "expected #{default_worker} to retry the default number of times but got true"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when expected is false' do
|
62
|
-
it 'returns message' do
|
63
|
-
expect(negative_subject.failure_message).to eq "expected #{negative_worker} to not retry but got false"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#matches?' do
|
69
|
-
context 'when condition matches' do
|
70
|
-
context 'when expected is a number' do
|
71
|
-
it 'returns true' do
|
72
|
-
expect(specific_subject.matches? specific_worker).to be true
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'when expected is true' do
|
77
|
-
it 'returns true' do
|
78
|
-
expect(default_subject.matches? default_worker).to be true
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when expected is false' do
|
83
|
-
it 'returns true' do
|
84
|
-
expect(negative_subject.matches? negative_worker).to be true
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'when condition does not match' do
|
90
|
-
context 'when expected is a number' do
|
91
|
-
it 'returns false' do
|
92
|
-
expect(specific_subject.matches? default_worker).to be false
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
context 'when expected is true' do
|
97
|
-
it 'returns false' do
|
98
|
-
expect(default_subject.matches? negative_worker).to be false
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context 'when expected is false' do
|
103
|
-
it 'returns false' do
|
104
|
-
expect(negative_subject.matches? specific_worker).to be false
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe '#failure_message_when_negated' do
|
111
|
-
context 'when expected is a number' do
|
112
|
-
it 'returns message' do
|
113
|
-
expect(specific_subject.failure_message_when_negated).to eq "expected #{specific_worker} to not retry 2 times"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context 'when expected is true' do
|
118
|
-
it 'returns message' do
|
119
|
-
expect(default_subject.failure_message_when_negated).to eq "expected #{default_worker} to not retry the default number of times"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context 'when expected is false' do
|
124
|
-
it 'returns message' do
|
125
|
-
expect(negative_subject.failure_message_when_negated).to eq "expected #{negative_worker} to retry"
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe RSpec::Sidekiq::Matchers::BeUnique do
|
4
|
-
shared_context 'a unique worker' do
|
5
|
-
before do
|
6
|
-
stub_const(module_constant, true)
|
7
|
-
end
|
8
|
-
before(:each) { subject.matches? @worker }
|
9
|
-
|
10
|
-
describe 'expected usage' do
|
11
|
-
it 'matches' do
|
12
|
-
expect(@worker).to be_unique
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '#failure_message' do
|
16
|
-
it 'returns message' do
|
17
|
-
expect(subject.failure_message).to eq "expected #{@worker} to be unique in the queue"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe '#matches?' do
|
23
|
-
context 'when condition matches' do
|
24
|
-
it 'returns true' do
|
25
|
-
expect(subject.matches? @worker).to be true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when condition does not match' do
|
30
|
-
it 'returns false' do
|
31
|
-
expect(subject.matches? create_worker unique: false).to be false
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#failure_message_when_negated' do
|
36
|
-
it 'returns message' do
|
37
|
-
expect(subject.failure_message_when_negated).to eq "expected #{@worker} to not be unique in the queue"
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '#description' do
|
43
|
-
it 'returns description' do
|
44
|
-
expect(subject.description).to eq 'be unique in the queue'
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'a sidekiq-enterprise scheduled worker' do
|
50
|
-
let(:interval) { 3.hours }
|
51
|
-
let(:module_constant) { "Sidekiq::Enterprise" }
|
52
|
-
before { @worker = create_worker unique_for: interval }
|
53
|
-
include_context 'a unique worker'
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'a sidekiq-unique-jobs scheduled worker' do
|
57
|
-
let(:module_constant) { "SidekiqUniqueJobs" }
|
58
|
-
before { @worker = create_worker unique: :all }
|
59
|
-
include_context 'a unique worker'
|
60
|
-
end
|
61
|
-
|
62
|
-
context 'a sidekiq-unique-jobs regular worker' do
|
63
|
-
let(:module_constant) { "SidekiqUniqueJobs" }
|
64
|
-
before { @worker = create_worker unique: true }
|
65
|
-
include_context 'a unique worker'
|
66
|
-
end
|
67
|
-
|
68
|
-
describe '#be_unique' do
|
69
|
-
before do
|
70
|
-
stub_const("SidekiqUniqueJobs", true)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'returns instance' do
|
74
|
-
expect(be_unique).to be_kind_of RSpec::Sidekiq::Matchers::BeUnique::Base
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#failure_message_when_negated' do
|
79
|
-
before do
|
80
|
-
stub_const("SidekiqUniqueJobs", true)
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'returns message' do
|
84
|
-
expect(subject.failure_message_when_negated).to eq "expected #{@worker} to not be unique in the queue"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe '#unique_key' do
|
89
|
-
context "with Sidekiq Enterprise" do
|
90
|
-
before do
|
91
|
-
stub_const("Sidekiq::Enterprise", true)
|
92
|
-
end
|
93
|
-
|
94
|
-
it "returns the correct key" do
|
95
|
-
expect(subject.unique_key).to eq('unique_for')
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "with sidekiq-unique-jobs" do
|
100
|
-
before do
|
101
|
-
stub_const("SidekiqUniqueJobs", true)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "returns the correct key" do
|
105
|
-
expect(subject.unique_key).to eq('unique')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "without a uniquing solution" do
|
110
|
-
it "raises an exception" do
|
111
|
-
expect{subject.unique_key}.to raise_error RuntimeError, 'No support found for Sidekiq unique jobs'
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,229 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
|
4
|
-
let(:tomorrow) { DateTime.now + 1 }
|
5
|
-
let(:interval) { 3.minutes }
|
6
|
-
let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args }
|
7
|
-
let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Integer), true, be_a(Hash)] }
|
8
|
-
let(:worker) { create_worker }
|
9
|
-
let(:worker_args) { ['string', 1, true, { key: 'value', bar: :foo, nested: [{hash: true}] }] }
|
10
|
-
let(:active_job) { create_active_job :mailers }
|
11
|
-
let(:resource) { TestResource.new }
|
12
|
-
|
13
|
-
before(:each) do
|
14
|
-
GlobalID.app = 'rspec-sidekiq'
|
15
|
-
worker.perform_async *worker_args
|
16
|
-
active_job.perform_later 'someResource'
|
17
|
-
active_job.perform_later(resource)
|
18
|
-
TestActionMailer.testmail.deliver_later
|
19
|
-
TestActionMailer.testmail(resource).deliver_later
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'expected usage' do
|
23
|
-
context 'Sidekiq' do
|
24
|
-
it 'matches' do
|
25
|
-
expect(worker).to have_enqueued_sidekiq_job *worker_args
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'matches on the global Worker queue' do
|
29
|
-
expect(Sidekiq::Worker).to have_enqueued_sidekiq_job *worker_args
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'perform_in' do
|
33
|
-
let(:worker_args_in) { worker_args + ['in'] }
|
34
|
-
|
35
|
-
before(:each) do
|
36
|
-
worker.perform_in 3.minutes, *worker_args_in
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'matches on an scheduled job with #perform_in' do
|
40
|
-
expect(worker).to have_enqueued_sidekiq_job(*worker_args_in).in(interval)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'perform_at' do
|
45
|
-
let(:worker_args_at) { worker_args + ['at'] }
|
46
|
-
|
47
|
-
before(:each) do
|
48
|
-
worker.perform_at tomorrow, *worker_args_at
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'matches on an scheduled job with #perform_at' do
|
52
|
-
expect(worker).to have_enqueued_sidekiq_job(*worker_args_at).at(tomorrow)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context 'ActiveJob' do
|
58
|
-
it 'matches on an enqueued ActiveJob' do
|
59
|
-
expect(Sidekiq::Worker).to have_enqueued_sidekiq_job 'someResource'
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'matches on an enqueued ActiveJob by global_id' do
|
63
|
-
expect(Sidekiq::Worker).to have_enqueued_sidekiq_job('_aj_globalid' => resource.to_global_id.uri.to_s)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'ActionMailer' do
|
68
|
-
it 'matches on ActionMailer Job' do
|
69
|
-
expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
|
70
|
-
'TestActionMailer',
|
71
|
-
'testmail',
|
72
|
-
'deliver_now'
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'matches on ActionMailer with a resource Job' do
|
77
|
-
expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
|
78
|
-
'TestActionMailer',
|
79
|
-
'testmail',
|
80
|
-
'deliver_now',
|
81
|
-
{ '_aj_globalid' => resource.to_global_id.uri.to_s }
|
82
|
-
)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#have_enqueued_sidekiq_job' do
|
88
|
-
it 'returns instance' do
|
89
|
-
expect(have_enqueued_sidekiq_job).to be_a RSpec::Sidekiq::Matchers::HaveEnqueuedJob
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe '#have_enqueued_job' do
|
94
|
-
it 'returns instance' do
|
95
|
-
expect(have_enqueued_job).to be_a RSpec::Sidekiq::Matchers::HaveEnqueuedJob
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'provides deprecation warning' do
|
99
|
-
expect { have_enqueued_job }.to output(/[DEPRECATION]/).to_stderr
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'matches the same way have_enqueued_sidekiq_job does' do
|
103
|
-
expect(worker).to have_enqueued_job *worker_args
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe '#description' do
|
108
|
-
it 'returns description' do
|
109
|
-
argument_subject.matches? worker
|
110
|
-
expect(argument_subject.description).to eq %{have an enqueued #{worker} job with arguments [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]}
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#failure_message' do
|
115
|
-
it 'returns message' do
|
116
|
-
argument_subject.matches? worker
|
117
|
-
expect(argument_subject.failure_message).to eq <<-eos.gsub(/^ {6}/, '').strip
|
118
|
-
expected to have an enqueued #{worker} job
|
119
|
-
arguments: [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]
|
120
|
-
found
|
121
|
-
arguments: [[\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]]
|
122
|
-
eos
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe '#failure_message_when_negated' do
|
127
|
-
it 'returns message' do
|
128
|
-
argument_subject.matches? worker
|
129
|
-
expect(argument_subject.failure_message_when_negated).to eq <<-eos.gsub(/^ {6}/, '').strip
|
130
|
-
expected not to have an enqueued #{worker} job
|
131
|
-
arguments: [\"string\", 1, true, {\"key\"=>\"value\", \"bar\"=>\"foo\", \"nested\"=>[{\"hash\"=>true}]}]
|
132
|
-
eos
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
describe '#matches?' do
|
137
|
-
context 'when condition matches' do
|
138
|
-
context 'when expected are arguments' do
|
139
|
-
it 'returns true' do
|
140
|
-
worker.perform_async *worker_args
|
141
|
-
expect(argument_subject.matches? worker).to be true
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'when expected are matchers' do
|
146
|
-
it 'returns true' do
|
147
|
-
worker.perform_async *worker_args
|
148
|
-
expect(matcher_subject.matches? worker).to be true
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'when job is scheduled' do
|
153
|
-
context 'with #perform_at' do
|
154
|
-
before(:each) do
|
155
|
-
worker.perform_at(tomorrow, *worker_args)
|
156
|
-
end
|
157
|
-
|
158
|
-
context 'and timestamp matches' do
|
159
|
-
it 'returns true' do
|
160
|
-
expect(matcher_subject.at(tomorrow).matches? worker).to be true
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
context 'and timestamp does not match' do
|
165
|
-
it 'returns false' do
|
166
|
-
expect(matcher_subject.at(tomorrow + 1).matches? worker).to be false
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context 'with #perform_in' do
|
172
|
-
before(:each) do
|
173
|
-
worker.perform_in(interval, *worker_args)
|
174
|
-
end
|
175
|
-
|
176
|
-
context 'and interval matches' do
|
177
|
-
it 'returns true' do
|
178
|
-
expect(matcher_subject.in(interval).matches? worker).to be true
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
context 'and interval does not match' do
|
183
|
-
it 'returns false' do
|
184
|
-
expect(matcher_subject.in(interval + 1.minute).matches? worker).to be false
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
context 'when condition does not match' do
|
192
|
-
before(:each) { Sidekiq::Worker.clear_all }
|
193
|
-
|
194
|
-
context 'when expected are arguments' do
|
195
|
-
it 'returns false' do
|
196
|
-
expect(argument_subject.matches? worker).to be false
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
context 'when expected are matchers' do
|
201
|
-
it 'returns false' do
|
202
|
-
expect(matcher_subject.matches? worker).to be false
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context 'when job is scheduled' do
|
207
|
-
context 'with #perform_at' do
|
208
|
-
before(:each) do
|
209
|
-
allow(matcher_subject).to receive(:options).and_return(at: tomorrow + 1)
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'returns false' do
|
213
|
-
expect(matcher_subject.at(tomorrow).matches? worker).to be false
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
context 'with #perform_in' do
|
218
|
-
before(:each) do
|
219
|
-
allow(matcher_subject).to receive(:options).and_return(in: interval + 1)
|
220
|
-
end
|
221
|
-
|
222
|
-
it 'returns false' do
|
223
|
-
expect(matcher_subject.in(interval).matches? worker).to be false
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|