rspec-sidekiq 2.2.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +34 -0
- data/README.md +35 -6
- data/lib/rspec/sidekiq/batch.rb +14 -3
- data/lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb +7 -3
- data/lib/rspec/sidekiq/matchers/be_retryable.rb +1 -1
- data/lib/rspec/sidekiq/matchers/be_unique.rb +68 -10
- data/lib/rspec/sidekiq/matchers/have_enqueued_job.rb +123 -18
- data/lib/rspec/sidekiq/matchers/save_backtrace.rb +1 -1
- data/lib/rspec/sidekiq/version.rb +1 -1
- data/rspec-sidekiq.gemspec +9 -5
- data/spec/rspec/sidekiq/batch_spec.rb +52 -9
- data/spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb +16 -4
- data/spec/rspec/sidekiq/matchers/be_unique_spec.rb +59 -6
- data/spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb +152 -33
- data/spec/spec_helper.rb +9 -4
- data/spec/support/test_resource.rb +1 -7
- metadata +72 -42
- data/spec/rspec/sidekiq/version_spec.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9521e2acad8dae8dc1c47afeb1a3f4f1052f44d2d512ae29866548f5cefdbb61
|
4
|
+
data.tar.gz: 4ce5c1b0a18cec884a1b023ae113f3e692afcc471c9e2dd067c762d6051a77d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3501020bc4f14f5294b1cb67483c3018f608111e4c50ec74c193927e0dadf41ad7532e5c2a695f7d107cd435094eb59751ab23743f6b97a316059f8cc77ba7f
|
7
|
+
data.tar.gz: 79003f53fa67a71b288a2de8d35bdc65aeb123e5dedf929e8012cff2e999aadaa5f3830d9d4dc33889ff4a270adbf9b1045a81e0b7372882b577e8d9553e8e9c
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
3.1.0
|
2
|
+
---
|
3
|
+
* Add support for latest ruby and Rails 5 (coding-bunny #156)
|
4
|
+
* Support `Class#method` notation in batch callback (caalberts #155)
|
5
|
+
* Fix bug with time comparison in delayed jobs (geeosh #153 with help from col)
|
6
|
+
* remove usage of `Integer#blank?` (lanej #152)
|
7
|
+
* Add `NullBatch#description` (dsantosmerino #139)
|
8
|
+
* README updates (BenMusch #142, akihikodaki #141, wpolicarpo #160)
|
9
|
+
|
10
|
+
3.0.3
|
11
|
+
---
|
12
|
+
* Re-splat arguments for the have_enqueued_job alias (aprescott #136)
|
13
|
+
|
14
|
+
3.0.2
|
15
|
+
---
|
16
|
+
* README updates (nilsding #110, packrat386 #122)
|
17
|
+
* Ruby 2.4 support (packrat386 #119)
|
18
|
+
* Fixes for Sidekiq 5 deprecations (packrat #130 with help from trev)
|
19
|
+
|
20
|
+
3.0.1
|
21
|
+
---
|
22
|
+
* Remove implicit runtime dependency on ActiveSupport [aprescott#109]
|
23
|
+
|
24
|
+
3.0.0
|
25
|
+
---
|
26
|
+
* Use default arguments for NullStatus initialization [briansharon#111]
|
27
|
+
* Fix at and in chainable methods [wpolicarpo#109]
|
28
|
+
* Rely on all of RSpec in development [packrat386#101]
|
29
|
+
* Pass exception to within_sidekiq_retries_exhausted_block [packrat386#100]
|
30
|
+
* Add support for testing scheduled jobs [wpolicarpo#81]
|
31
|
+
* only depend on rspec-core [urkle#96]
|
32
|
+
* Add support for Sidekiq Enterprise [Geesu#82]
|
33
|
+
* Fix clash with rspec-rails [pavel-jurasek-bcgdv-com#95]
|
34
|
+
|
1
35
|
2.2.0
|
2
36
|
---
|
3
37
|
* Fix typo in README file [bradhaydon#87]
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
**Welcome @packrat386 as new maintainer for `rspec-sidekiq`!**
|
2
|
+
|
1
3
|
# RSpec for Sidekiq
|
2
4
|
|
3
5
|
[![RubyGems][gem_version_badge]][ruby_gems]
|
@@ -50,7 +52,7 @@ end
|
|
50
52
|
* [be_processed_in](#be_processed_in)
|
51
53
|
* [be_retryable](#be_retryable)
|
52
54
|
* [be_unique](#be_unique)
|
53
|
-
* [
|
55
|
+
* [have_enqueued_sidekiq_job](#have_enqueued_sidekiq_job)
|
54
56
|
|
55
57
|
### be_delayed
|
56
58
|
*Describes a method that should be invoked asynchronously (See [Sidekiq Delayed Extensions][sidekiq_wiki_delayed_extensions])*
|
@@ -85,7 +87,7 @@ it { is_expected.to be_processed_in :download }
|
|
85
87
|
```
|
86
88
|
|
87
89
|
### be_retryable
|
88
|
-
*Describes if a job should retry when there is a failure in
|
90
|
+
*Describes if a job should retry when there is a failure in its execution*
|
89
91
|
```ruby
|
90
92
|
sidekiq_options retry: 5
|
91
93
|
# test with...
|
@@ -100,7 +102,7 @@ it { is_expected.to be_retryable false }
|
|
100
102
|
```
|
101
103
|
|
102
104
|
### save_backtrace
|
103
|
-
*Describes if a job should save the error backtrace when there is a failure in
|
105
|
+
*Describes if a job should save the error backtrace when there is a failure in its execution*
|
104
106
|
```ruby
|
105
107
|
sidekiq_options backtrace: 5
|
106
108
|
# test with...
|
@@ -117,13 +119,14 @@ it { is_expected.to save_backtrace false }
|
|
117
119
|
```
|
118
120
|
|
119
121
|
### be_unique
|
120
|
-
*Describes when a job should be unique within
|
122
|
+
*Describes when a job should be unique within its queue*
|
121
123
|
```ruby
|
122
124
|
sidekiq_options unique: true
|
123
125
|
# test with...
|
124
126
|
expect(AwesomeJob).to be_unique
|
125
127
|
it { is_expected.to be_unique }
|
126
128
|
```
|
129
|
+
|
127
130
|
### be_expired_in
|
128
131
|
*Describes when a job should expire*
|
129
132
|
```ruby
|
@@ -133,14 +136,36 @@ it { is_expected.to be_expired_in 1.hour }
|
|
133
136
|
it { is_expected.to_not be_expired_in 2.hours }
|
134
137
|
```
|
135
138
|
|
136
|
-
###
|
139
|
+
### have_enqueued_sidekiq_job
|
137
140
|
*Describes that there should be an enqueued job with the specified arguments*
|
141
|
+
|
142
|
+
**Note:** When using rspec-rails >= 3.4, use `have_enqueued_sidekiq_job` instead to
|
143
|
+
prevent a name clash with rspec-rails' ActiveJob matcher.
|
144
|
+
|
138
145
|
```ruby
|
139
146
|
AwesomeJob.perform_async 'Awesome', true
|
140
147
|
# test with...
|
148
|
+
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true)
|
149
|
+
|
150
|
+
# Code written with older versions of the gem may use the deprecated
|
151
|
+
# have_enqueued_job matcher.
|
141
152
|
expect(AwesomeJob).to have_enqueued_job('Awesome', true)
|
142
153
|
```
|
143
154
|
|
155
|
+
#### Testing scheduled jobs
|
156
|
+
*Use chainable matchers `#at` and `#in`*
|
157
|
+
```ruby
|
158
|
+
time = 5.minutes.from_now
|
159
|
+
Awesomejob.perform_at time, 'Awesome', true
|
160
|
+
# test with...
|
161
|
+
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).at(time)
|
162
|
+
```
|
163
|
+
```ruby
|
164
|
+
Awesomejob.perform_in 5.minutes, 'Awesome', true
|
165
|
+
# test with...
|
166
|
+
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(5.minutes)
|
167
|
+
```
|
168
|
+
|
144
169
|
## Example matcher usage
|
145
170
|
```ruby
|
146
171
|
require 'spec_helper'
|
@@ -154,7 +179,7 @@ describe AwesomeJob do
|
|
154
179
|
it 'enqueues another awesome job' do
|
155
180
|
subject.perform
|
156
181
|
|
157
|
-
expect(AnotherAwesomeJob).to
|
182
|
+
expect(AnotherAwesomeJob).to have_enqueued_sidekiq_job('Awesome', true)
|
158
183
|
end
|
159
184
|
end
|
160
185
|
```
|
@@ -180,6 +205,10 @@ FooClass.within_sidekiq_retries_exhausted_block {
|
|
180
205
|
## Testing
|
181
206
|
```bundle exec rspec spec```
|
182
207
|
|
208
|
+
## Maintainers
|
209
|
+
* @packrat386
|
210
|
+
* @philostler
|
211
|
+
|
183
212
|
## Contribute
|
184
213
|
Please do! If there's a feature missing that you'd love to see then get in on the action!
|
185
214
|
|
data/lib/rspec/sidekiq/batch.rb
CHANGED
@@ -10,6 +10,7 @@ if defined? Sidekiq::Batch
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class NullBatch < NullObject
|
13
|
+
attr_accessor :description
|
13
14
|
attr_reader :bid
|
14
15
|
|
15
16
|
def initialize(bid = nil)
|
@@ -33,7 +34,7 @@ if defined? Sidekiq::Batch
|
|
33
34
|
class NullStatus < NullObject
|
34
35
|
attr_reader :bid
|
35
36
|
|
36
|
-
def initialize(bid, callbacks)
|
37
|
+
def initialize(bid = SecureRandom.hex(8), callbacks = [])
|
37
38
|
@bid = bid
|
38
39
|
@callbacks = callbacks
|
39
40
|
end
|
@@ -45,9 +46,17 @@ if defined? Sidekiq::Batch
|
|
45
46
|
def join
|
46
47
|
::Sidekiq::Worker.drain_all
|
47
48
|
|
48
|
-
@callbacks.each do |event,
|
49
|
+
@callbacks.each do |event, callback, options|
|
49
50
|
if event != :success || failures == 0
|
50
|
-
|
51
|
+
case callback
|
52
|
+
when Class
|
53
|
+
callback.new.send("on_#{event}", self, options)
|
54
|
+
when String
|
55
|
+
klass, meth = callback.split('#')
|
56
|
+
klass.constantize.new.send(meth, self, options)
|
57
|
+
else
|
58
|
+
raise ArgumentError, 'Unsupported callback notation'
|
59
|
+
end
|
51
60
|
end
|
52
61
|
end
|
53
62
|
end
|
@@ -59,6 +68,7 @@ if defined? Sidekiq::Batch
|
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
71
|
+
# :nocov:
|
62
72
|
RSpec.configure do |config|
|
63
73
|
config.before(:each) do |example|
|
64
74
|
next if example.metadata[:stub_batches] == false
|
@@ -76,4 +86,5 @@ if defined? Sidekiq::Batch
|
|
76
86
|
def mocked_with_mocha?
|
77
87
|
Sidekiq::Batch.respond_to? :stubs
|
78
88
|
end
|
89
|
+
# :nocov:
|
79
90
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Sidekiq
|
2
2
|
module Worker
|
3
3
|
module ClassMethods
|
4
|
-
def within_sidekiq_retries_exhausted_block(user_msg = {}, &block)
|
4
|
+
def within_sidekiq_retries_exhausted_block(user_msg = {}, exception = default_retries_exhausted_exception, &block)
|
5
5
|
block.call
|
6
|
-
sidekiq_retries_exhausted_block.call
|
6
|
+
sidekiq_retries_exhausted_block.call(default_retries_exhausted_message.merge(user_msg), exception)
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def default_retries_exhausted_message
|
10
10
|
{
|
11
11
|
'queue' => get_sidekiq_options[:worker],
|
12
12
|
'class' => name,
|
@@ -14,6 +14,10 @@ module Sidekiq
|
|
14
14
|
'error_message' => 'An error occured'
|
15
15
|
}
|
16
16
|
end
|
17
|
+
|
18
|
+
def default_retries_exhausted_exception
|
19
|
+
StandardError.new('An error occured')
|
20
|
+
end
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -6,22 +6,80 @@ module RSpec
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class BeUnique
|
9
|
-
def
|
10
|
-
|
9
|
+
def self.new
|
10
|
+
if defined?(::Sidekiq::Enterprise)
|
11
|
+
SidekiqEnterprise.new
|
12
|
+
elsif defined?(::SidekiqUniqueJobs)
|
13
|
+
SidekiqUniqueJobs.new
|
14
|
+
else
|
15
|
+
fail "No support found for Sidekiq unique jobs"
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
|
-
|
14
|
-
|
19
|
+
class Base
|
20
|
+
def description
|
21
|
+
'be unique in the queue'
|
22
|
+
end
|
23
|
+
|
24
|
+
def failure_message
|
25
|
+
if !interval_matches? && @expected_interval
|
26
|
+
"expected #{@klass} to be unique for #{@expected_interval} seconds, "\
|
27
|
+
"but its interval was #{actual_interval} seconds"
|
28
|
+
else
|
29
|
+
"expected #{@klass} to be unique in the queue"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def matches?(job)
|
34
|
+
@klass = job.is_a?(Class) ? job : job.class
|
35
|
+
@actual = @klass.get_sidekiq_options[unique_key]
|
36
|
+
!!(value_matches? && interval_matches?)
|
37
|
+
end
|
38
|
+
|
39
|
+
def for(interval)
|
40
|
+
@expected_interval = interval
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def interval_specified?
|
45
|
+
@expected_interval
|
46
|
+
end
|
47
|
+
|
48
|
+
def interval_matches?
|
49
|
+
!interval_specified? || actual_interval == @expected_interval
|
50
|
+
end
|
51
|
+
|
52
|
+
def failure_message_when_negated
|
53
|
+
"expected #{@klass} to not be unique in the queue"
|
54
|
+
end
|
15
55
|
end
|
16
56
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
57
|
+
class SidekiqUniqueJobs < Base
|
58
|
+
def actual_interval
|
59
|
+
@klass.get_sidekiq_options['unique_job_expiration']
|
60
|
+
end
|
61
|
+
|
62
|
+
def value_matches?
|
63
|
+
[true, :all].include?(@actual)
|
64
|
+
end
|
65
|
+
|
66
|
+
def unique_key
|
67
|
+
'unique'
|
68
|
+
end
|
21
69
|
end
|
22
70
|
|
23
|
-
|
24
|
-
|
71
|
+
class SidekiqEnterprise < Base
|
72
|
+
def actual_interval
|
73
|
+
@actual
|
74
|
+
end
|
75
|
+
|
76
|
+
def value_matches?
|
77
|
+
@actual && @actual > 0
|
78
|
+
end
|
79
|
+
|
80
|
+
def unique_key
|
81
|
+
'unique_for'
|
82
|
+
end
|
25
83
|
end
|
26
84
|
end
|
27
85
|
end
|
@@ -1,15 +1,114 @@
|
|
1
1
|
module RSpec
|
2
2
|
module Sidekiq
|
3
3
|
module Matchers
|
4
|
-
def
|
4
|
+
def have_enqueued_sidekiq_job(*expected_arguments)
|
5
5
|
HaveEnqueuedJob.new expected_arguments
|
6
6
|
end
|
7
7
|
|
8
|
+
def have_enqueued_job(*expected_arguments)
|
9
|
+
warn "[DEPRECATION] `have_enqueued_job` is deprecated. Please use `have_enqueued_sidekiq_job` instead."
|
10
|
+
have_enqueued_sidekiq_job(*expected_arguments)
|
11
|
+
end
|
12
|
+
|
13
|
+
class JobOptionParser
|
14
|
+
attr_reader :job
|
15
|
+
|
16
|
+
def initialize(job)
|
17
|
+
@job = job
|
18
|
+
end
|
19
|
+
|
20
|
+
def matches?(option, value)
|
21
|
+
raise ArgumentError, "Option `#{option}` is not defined." unless %w(in at).include?(option.to_s)
|
22
|
+
send("#{option}_evaluator", value)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def at_evaluator(value)
|
28
|
+
return false if job['at'].to_s.empty?
|
29
|
+
value.to_time.to_i == Time.at(job['at']).to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
def in_evaluator(value)
|
33
|
+
return false if job['at'].to_s.empty?
|
34
|
+
(Time.now + value).to_i == Time.at(job['at']).to_i
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class JobMatcher
|
39
|
+
attr_reader :jobs
|
40
|
+
|
41
|
+
def initialize(klass)
|
42
|
+
@jobs = unwrap_jobs(klass.jobs)
|
43
|
+
end
|
44
|
+
|
45
|
+
def present?(arguments, options)
|
46
|
+
!!find_job(arguments, options)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def matches?(job, arguments, options)
|
52
|
+
arguments_matches?(job, arguments) &&
|
53
|
+
options_matches?(job, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def arguments_matches?(job, arguments)
|
57
|
+
arguments_got = job_arguments(job)
|
58
|
+
contain_exactly?(arguments, arguments_got)
|
59
|
+
end
|
60
|
+
|
61
|
+
def options_matches?(job, options)
|
62
|
+
options.all? do |option, value|
|
63
|
+
parser = JobOptionParser.new(job)
|
64
|
+
parser.matches?(option, value)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_job(arguments, options)
|
69
|
+
jobs.find { |job| matches?(job, arguments, options) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def job_arguments(job)
|
73
|
+
args = job['args']
|
74
|
+
return args[0]['arguments'] if args.is_a?(Array) && args[0].is_a?(Hash) && args[0].has_key?('arguments')
|
75
|
+
args
|
76
|
+
end
|
77
|
+
|
78
|
+
def unwrap_jobs(jobs)
|
79
|
+
return jobs if jobs.is_a?(Array)
|
80
|
+
jobs.values.flatten
|
81
|
+
end
|
82
|
+
|
83
|
+
def contain_exactly?(expected, got)
|
84
|
+
exactly = RSpec::Matchers::BuiltIn::ContainExactly.new(expected)
|
85
|
+
exactly.matches?(got)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
8
89
|
class HaveEnqueuedJob
|
9
|
-
attr_reader :klass, :expected_arguments, :
|
90
|
+
attr_reader :klass, :expected_arguments, :actual_arguments, :expected_options, :actual_options
|
10
91
|
|
11
92
|
def initialize(expected_arguments)
|
12
93
|
@expected_arguments = normalize_arguments(expected_arguments)
|
94
|
+
@expected_options = {}
|
95
|
+
end
|
96
|
+
|
97
|
+
def matches?(klass)
|
98
|
+
@klass = klass
|
99
|
+
@actual_arguments = unwrapped_job_arguments(klass.jobs)
|
100
|
+
@actual_options = unwrapped_job_options(klass.jobs)
|
101
|
+
JobMatcher.new(klass).present?(expected_arguments, expected_options)
|
102
|
+
end
|
103
|
+
|
104
|
+
def at(timestamp)
|
105
|
+
@expected_options['at'] = timestamp
|
106
|
+
self
|
107
|
+
end
|
108
|
+
|
109
|
+
def in(interval)
|
110
|
+
@expected_options['in'] = interval
|
111
|
+
self
|
13
112
|
end
|
14
113
|
|
15
114
|
def description
|
@@ -17,30 +116,39 @@ module RSpec
|
|
17
116
|
end
|
18
117
|
|
19
118
|
def failure_message
|
20
|
-
"expected to have an enqueued #{klass} job
|
21
|
-
"
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@actual.any? { |arguments| contain_exactly?(arguments) }
|
119
|
+
message = ["expected to have an enqueued #{klass} job"]
|
120
|
+
message << " arguments: #{expected_arguments}" if expected_arguments
|
121
|
+
message << " options: #{expected_options}" if expected_options.any?
|
122
|
+
message << "found"
|
123
|
+
message << " arguments: #{actual_arguments}" if expected_arguments
|
124
|
+
message << " options: #{actual_options}" if expected_options.any?
|
125
|
+
message.join("\n")
|
28
126
|
end
|
29
127
|
|
30
128
|
def failure_message_when_negated
|
31
|
-
"expected to
|
129
|
+
message = ["expected not to have an enqueued #{klass} job"]
|
130
|
+
message << " arguments: #{expected_arguments}" if expected_arguments.any?
|
131
|
+
message << " options: #{expected_options}" if expected_options.any?
|
132
|
+
message.join("\n")
|
32
133
|
end
|
33
134
|
|
34
135
|
private
|
35
136
|
|
137
|
+
def unwrapped_job_options(jobs)
|
138
|
+
jobs = jobs.values if jobs.is_a?(Hash)
|
139
|
+
jobs.flatten.map do |job|
|
140
|
+
{ 'at' => job['at'] }
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
36
144
|
def unwrapped_job_arguments(jobs)
|
37
145
|
if jobs.is_a? Hash
|
38
146
|
jobs.values.flatten.map do |job|
|
39
|
-
map_arguments(job)
|
147
|
+
map_arguments(job)
|
40
148
|
end
|
41
149
|
else
|
42
150
|
map_arguments(jobs)
|
43
|
-
end
|
151
|
+
end.map { |job| job.flatten }
|
44
152
|
end
|
45
153
|
|
46
154
|
def map_arguments(job)
|
@@ -56,11 +164,6 @@ module RSpec
|
|
56
164
|
hash['arguments'] || hash['args'] if hash.is_a? Hash
|
57
165
|
end
|
58
166
|
|
59
|
-
def contain_exactly?(arguments)
|
60
|
-
exactly = RSpec::Matchers::BuiltIn::ContainExactly.new(expected_arguments)
|
61
|
-
exactly.matches?(arguments)
|
62
|
-
end
|
63
|
-
|
64
167
|
def normalize_arguments(args)
|
65
168
|
if args.is_a?(Array)
|
66
169
|
args.map{ |x| normalize_arguments(x) }
|
@@ -68,6 +171,8 @@ module RSpec
|
|
68
171
|
args.each_with_object({}) do |(key, value), hash|
|
69
172
|
hash[key.to_s] = normalize_arguments(value)
|
70
173
|
end
|
174
|
+
elsif args.is_a?(Symbol)
|
175
|
+
args.to_s
|
71
176
|
else
|
72
177
|
args
|
73
178
|
end
|
@@ -11,7 +11,7 @@ module RSpec
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def description
|
14
|
-
if @expected_backtrace.is_a?(
|
14
|
+
if @expected_backtrace.is_a?(Numeric)
|
15
15
|
"save #{@expected_backtrace} lines of error backtrace" # backtrace: 5
|
16
16
|
elsif @expected_backtrace
|
17
17
|
'save error backtrace' # backtrace: true
|
data/rspec-sidekiq.gemspec
CHANGED
@@ -11,13 +11,17 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.description = 'Simple testing of Sidekiq jobs via a collection of matchers and helpers'
|
12
12
|
s.license = 'MIT'
|
13
13
|
|
14
|
-
s.add_dependency 'rspec', '~> 3.0', '>= 3.0.0'
|
14
|
+
s.add_dependency 'rspec-core', '~> 3.0', '>= 3.0.0'
|
15
15
|
s.add_dependency 'sidekiq', '>= 2.4.0'
|
16
16
|
|
17
|
-
s.add_development_dependency '
|
18
|
-
s.add_development_dependency '
|
19
|
-
s.add_development_dependency '
|
20
|
-
s.add_development_dependency '
|
17
|
+
s.add_development_dependency 'rspec'
|
18
|
+
s.add_development_dependency 'coveralls'
|
19
|
+
s.add_development_dependency 'fuubar'
|
20
|
+
s.add_development_dependency 'activejob'
|
21
|
+
s.add_development_dependency 'actionmailer'
|
22
|
+
s.add_development_dependency 'activerecord'
|
23
|
+
s.add_development_dependency 'activemodel'
|
24
|
+
s.add_development_dependency 'activesupport'
|
21
25
|
|
22
26
|
|
23
27
|
s.files = Dir['.gitattributes'] +
|
@@ -10,31 +10,74 @@ RSpec.describe 'Batch' do
|
|
10
10
|
|
11
11
|
load File.expand_path(File.join(File.dirname(__FILE__), '../../../lib/rspec/sidekiq/batch.rb'))
|
12
12
|
|
13
|
+
describe 'NullObject' do
|
14
|
+
describe '#method_missing' do
|
15
|
+
it 'returns itself' do
|
16
|
+
batch = Sidekiq::Batch.new
|
17
|
+
expect(batch.non_existent_method).to eq(batch)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'NullBatch' do
|
23
|
+
end
|
24
|
+
|
13
25
|
describe 'NullStatus' do
|
26
|
+
let(:batch) { Sidekiq::Batch.new }
|
27
|
+
|
28
|
+
subject { batch.status }
|
29
|
+
|
14
30
|
describe '#total' do
|
15
31
|
it 'returns 0 when no jobs' do
|
16
|
-
|
17
|
-
expect(null_status.total).to eq(0)
|
32
|
+
expect(subject.total).to eq(0)
|
18
33
|
end
|
19
34
|
|
20
35
|
it 'returns 1 when 1 job' do
|
21
|
-
batch = Sidekiq::Batch.new
|
22
|
-
|
23
36
|
batch.jobs do
|
24
37
|
TestWorker.perform_async('5')
|
25
38
|
end
|
26
39
|
|
27
|
-
|
40
|
+
expect(subject.total).to eq(1)
|
41
|
+
end
|
42
|
+
end
|
28
43
|
|
29
|
-
|
44
|
+
describe '#failures' do
|
45
|
+
it 'returns 0' do
|
46
|
+
expect(subject.failures).to eq(0)
|
30
47
|
end
|
31
48
|
end
|
32
49
|
|
33
50
|
describe '#bid' do
|
34
51
|
it 'returns a bid' do
|
35
|
-
|
36
|
-
|
52
|
+
expect(subject.bid).to_not be_nil
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#join' do
|
57
|
+
class MyCallback
|
58
|
+
def on_event(status, options); end
|
59
|
+
end
|
60
|
+
|
61
|
+
class OtherCallback
|
62
|
+
def foo(status, options); end
|
63
|
+
end
|
64
|
+
|
65
|
+
before(:each) do
|
66
|
+
batch.on(:event, MyCallback, my_arg: 42)
|
67
|
+
batch.on(:event, 'OtherCallback#foo', my_arg: 23)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'executes callbacks' do
|
71
|
+
expect_any_instance_of(MyCallback).to receive(:on_event).with(subject, { my_arg: 42 })
|
72
|
+
expect_any_instance_of(OtherCallback).to receive(:foo).with(subject, { my_arg: 23 })
|
73
|
+
subject.join
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#initialize' do
|
78
|
+
it 'uses default argument values when none are provided' do
|
79
|
+
expect { Sidekiq::Batch::Status.new }.to_not raise_error
|
37
80
|
end
|
38
81
|
end
|
39
82
|
end
|
40
|
-
end
|
83
|
+
end
|
@@ -2,9 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe 'Retries Exhausted block' do
|
4
4
|
class FooClass < TestWorkerAlternative
|
5
|
-
sidekiq_retries_exhausted do |msg|
|
5
|
+
sidekiq_retries_exhausted do |msg, exception|
|
6
6
|
bar('hello')
|
7
7
|
foo(msg)
|
8
|
+
baz(exception)
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.bar(input)
|
@@ -12,17 +13,28 @@ RSpec.describe 'Retries Exhausted block' do
|
|
12
13
|
|
13
14
|
def self.foo(msg)
|
14
15
|
end
|
16
|
+
|
17
|
+
def self.baz(exception)
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
it 'executes whatever is within the block' do
|
18
22
|
FooClass.within_sidekiq_retries_exhausted_block { expect(FooClass).to receive(:bar).with('hello') }
|
19
23
|
end
|
20
24
|
|
21
|
-
it 'passes
|
25
|
+
it 'passes message and exception to the block' do
|
22
26
|
args = { 'args' => ['a', 'b']}
|
23
|
-
|
24
|
-
|
27
|
+
exception = StandardError.new('something went wrong')
|
28
|
+
FooClass.within_sidekiq_retries_exhausted_block(args, exception) do
|
29
|
+
expect(FooClass).to receive(:foo).with(FooClass.default_retries_exhausted_message.merge(args))
|
30
|
+
expect(FooClass).to receive(:baz).with(exception)
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
34
|
+
it 'sets a default value for the message and exception' do
|
35
|
+
FooClass.within_sidekiq_retries_exhausted_block do
|
36
|
+
expect(FooClass).to receive(:foo).with(FooClass.default_retries_exhausted_message)
|
37
|
+
expect(FooClass).to receive(:baz).with(FooClass.default_retries_exhausted_exception)
|
38
|
+
end
|
39
|
+
end
|
28
40
|
end
|
@@ -2,6 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe RSpec::Sidekiq::Matchers::BeUnique do
|
4
4
|
shared_context 'a unique worker' do
|
5
|
+
before do
|
6
|
+
stub_const(module_constant, true)
|
7
|
+
end
|
5
8
|
before(:each) { subject.matches? @worker }
|
6
9
|
|
7
10
|
describe 'expected usage' do
|
@@ -14,7 +17,6 @@ RSpec.describe RSpec::Sidekiq::Matchers::BeUnique do
|
|
14
17
|
expect(subject.failure_message).to eq "expected #{@worker} to be unique in the queue"
|
15
18
|
end
|
16
19
|
end
|
17
|
-
|
18
20
|
end
|
19
21
|
|
20
22
|
describe '#matches?' do
|
@@ -36,27 +38,78 @@ RSpec.describe RSpec::Sidekiq::Matchers::BeUnique do
|
|
36
38
|
end
|
37
39
|
end
|
38
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
|
39
47
|
end
|
40
48
|
|
41
|
-
context 'a scheduled worker' do
|
42
|
-
|
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 }
|
43
53
|
include_context 'a unique worker'
|
44
54
|
end
|
45
55
|
|
46
|
-
context 'a
|
47
|
-
|
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 }
|
48
65
|
include_context 'a unique worker'
|
49
66
|
end
|
50
67
|
|
51
68
|
describe '#be_unique' do
|
69
|
+
before do
|
70
|
+
stub_const("SidekiqUniqueJobs", true)
|
71
|
+
end
|
72
|
+
|
52
73
|
it 'returns instance' do
|
53
|
-
expect(be_unique).to
|
74
|
+
expect(be_unique).to be_kind_of RSpec::Sidekiq::Matchers::BeUnique::Base
|
54
75
|
end
|
55
76
|
end
|
56
77
|
|
57
78
|
describe '#failure_message_when_negated' do
|
79
|
+
before do
|
80
|
+
stub_const("SidekiqUniqueJobs", true)
|
81
|
+
end
|
82
|
+
|
58
83
|
it 'returns message' do
|
59
84
|
expect(subject.failure_message_when_negated).to eq "expected #{@worker} to not be unique in the queue"
|
60
85
|
end
|
61
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
|
62
115
|
end
|
@@ -1,54 +1,92 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
|
4
|
+
let(:tomorrow) { DateTime.now + 1 }
|
5
|
+
let(:interval) { 3.minutes }
|
4
6
|
let(:argument_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new worker_args }
|
5
|
-
let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(
|
7
|
+
let(:matcher_subject) { RSpec::Sidekiq::Matchers::HaveEnqueuedJob.new [be_a(String), be_a(Integer), true, be_a(Hash)] }
|
6
8
|
let(:worker) { create_worker }
|
7
|
-
let(:worker_args) { ['string', 1, true, {key: 'value', nested: [{hash: true}]}] }
|
9
|
+
let(:worker_args) { ['string', 1, true, { key: 'value', bar: :foo, nested: [{hash: true}] }] }
|
8
10
|
let(:active_job) { create_active_job :mailers }
|
9
11
|
let(:resource) { TestResource.new }
|
10
12
|
|
11
13
|
before(:each) do
|
14
|
+
GlobalID.app = 'rspec-sidekiq'
|
12
15
|
worker.perform_async *worker_args
|
13
16
|
active_job.perform_later 'someResource'
|
14
17
|
active_job.perform_later(resource)
|
15
18
|
TestActionMailer.testmail.deliver_later
|
16
19
|
TestActionMailer.testmail(resource).deliver_later
|
17
|
-
argument_subject.matches? worker
|
18
20
|
end
|
19
21
|
|
20
22
|
describe 'expected usage' do
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
context 'Sidekiq' do
|
24
|
+
it 'matches' do
|
25
|
+
expect(worker).to have_enqueued_sidekiq_job *worker_args
|
26
|
+
end
|
24
27
|
|
25
|
-
|
26
|
-
|
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'] }
|
28
34
|
|
29
|
-
|
30
|
-
|
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
|
31
55
|
end
|
32
56
|
|
33
|
-
|
34
|
-
|
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
|
35
65
|
end
|
36
66
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
43
84
|
end
|
85
|
+
end
|
44
86
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
"testmail",
|
49
|
-
"deliver_now",
|
50
|
-
{ "_aj_globalid" => resource.to_global_id.uri.to_s }
|
51
|
-
)
|
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
|
52
90
|
end
|
53
91
|
end
|
54
92
|
|
@@ -56,17 +94,42 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
|
|
56
94
|
it 'returns instance' do
|
57
95
|
expect(have_enqueued_job).to be_a RSpec::Sidekiq::Matchers::HaveEnqueuedJob
|
58
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
|
59
105
|
end
|
60
106
|
|
61
107
|
describe '#description' do
|
62
108
|
it 'returns description' do
|
63
|
-
|
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}]}]}
|
64
111
|
end
|
65
112
|
end
|
66
113
|
|
67
114
|
describe '#failure_message' do
|
68
115
|
it 'returns message' do
|
69
|
-
|
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
|
70
133
|
end
|
71
134
|
end
|
72
135
|
|
@@ -74,15 +137,55 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
|
|
74
137
|
context 'when condition matches' do
|
75
138
|
context 'when expected are arguments' do
|
76
139
|
it 'returns true' do
|
140
|
+
worker.perform_async *worker_args
|
77
141
|
expect(argument_subject.matches? worker).to be true
|
78
142
|
end
|
79
143
|
end
|
80
144
|
|
81
145
|
context 'when expected are matchers' do
|
82
146
|
it 'returns true' do
|
147
|
+
worker.perform_async *worker_args
|
83
148
|
expect(matcher_subject.matches? worker).to be true
|
84
149
|
end
|
85
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
|
86
189
|
end
|
87
190
|
|
88
191
|
context 'when condition does not match' do
|
@@ -99,12 +202,28 @@ RSpec.describe RSpec::Sidekiq::Matchers::HaveEnqueuedJob do
|
|
99
202
|
expect(matcher_subject.matches? worker).to be false
|
100
203
|
end
|
101
204
|
end
|
102
|
-
end
|
103
|
-
end
|
104
205
|
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
108
227
|
end
|
109
228
|
end
|
110
229
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -9,10 +9,9 @@ require 'action_mailer'
|
|
9
9
|
|
10
10
|
require_relative 'support/init'
|
11
11
|
|
12
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter
|
13
|
-
Coveralls::SimpleCov::Formatter,
|
14
|
-
|
15
|
-
]
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
13
|
+
[Coveralls::SimpleCov::Formatter, SimpleCov::Formatter::HTMLFormatter]
|
14
|
+
)
|
16
15
|
SimpleCov.start
|
17
16
|
|
18
17
|
RSpec.configure do |config|
|
@@ -22,3 +21,9 @@ RSpec.configure do |config|
|
|
22
21
|
end
|
23
22
|
|
24
23
|
ActiveJob::Base.queue_adapter = :sidekiq
|
24
|
+
|
25
|
+
if Gem::Dependency.new('sidekiq', '>= 5.0.0').matching_specs.any?
|
26
|
+
require 'active_record'
|
27
|
+
ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
|
28
|
+
Sidekiq::Extensions.enable_delay!
|
29
|
+
end
|
@@ -1,16 +1,10 @@
|
|
1
1
|
class TestResource
|
2
2
|
include GlobalID::Identification
|
3
3
|
|
4
|
-
attr_reader :global_id
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@global_id = GlobalID.create(self, { app: 'rspec-sidekiq' })
|
8
|
-
end
|
9
|
-
|
10
4
|
def self.find(id)
|
11
5
|
end
|
12
6
|
|
13
7
|
def id
|
14
|
-
rand(36**10).to_s 36
|
8
|
+
@id ||= rand(36**10).to_s 36
|
15
9
|
end
|
16
10
|
end
|
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Ostler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: rspec
|
14
|
+
name: rspec-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3.0'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 3.0.0
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '3.0'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 3.0.0
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: sidekiq
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,85 +45,117 @@ dependencies:
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 2.4.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: rspec
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0.8'
|
54
51
|
- - ">="
|
55
52
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0
|
53
|
+
version: '0'
|
57
54
|
type: :development
|
58
55
|
prerelease: false
|
59
56
|
version_requirements: !ruby/object:Gem::Requirement
|
60
57
|
requirements:
|
61
|
-
- - "
|
58
|
+
- - ">="
|
62
59
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: coveralls
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
64
65
|
- - ">="
|
65
66
|
- !ruby/object:Gem::Version
|
66
|
-
version: 0
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
67
75
|
- !ruby/object:Gem::Dependency
|
68
76
|
name: fuubar
|
69
77
|
requirement: !ruby/object:Gem::Requirement
|
70
78
|
requirements:
|
71
|
-
- - "~>"
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version: '2.0'
|
74
79
|
- - ">="
|
75
80
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
81
|
+
version: '0'
|
77
82
|
type: :development
|
78
83
|
prerelease: false
|
79
84
|
version_requirements: !ruby/object:Gem::Requirement
|
80
85
|
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '2.0'
|
84
86
|
- - ">="
|
85
87
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
88
|
+
version: '0'
|
87
89
|
- !ruby/object:Gem::Dependency
|
88
90
|
name: activejob
|
89
91
|
requirement: !ruby/object:Gem::Requirement
|
90
92
|
requirements:
|
91
|
-
- - "~>"
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '4.2'
|
94
93
|
- - ">="
|
95
94
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
95
|
+
version: '0'
|
97
96
|
type: :development
|
98
97
|
prerelease: false
|
99
98
|
version_requirements: !ruby/object:Gem::Requirement
|
100
99
|
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '4.2'
|
104
100
|
- - ">="
|
105
101
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
102
|
+
version: '0'
|
107
103
|
- !ruby/object:Gem::Dependency
|
108
104
|
name: actionmailer
|
109
105
|
requirement: !ruby/object:Gem::Requirement
|
110
106
|
requirements:
|
111
|
-
- - "
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
112
115
|
- !ruby/object:Gem::Version
|
113
|
-
version: '
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: activerecord
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
114
121
|
- - ">="
|
115
122
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
123
|
+
version: '0'
|
117
124
|
type: :development
|
118
125
|
prerelease: false
|
119
126
|
version_requirements: !ruby/object:Gem::Requirement
|
120
127
|
requirements:
|
121
|
-
- - "
|
128
|
+
- - ">="
|
122
129
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: activemodel
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: activesupport
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
124
156
|
- - ">="
|
125
157
|
- !ruby/object:Gem::Version
|
126
|
-
version:
|
158
|
+
version: '0'
|
127
159
|
description: Simple testing of Sidekiq jobs via a collection of matchers and helpers
|
128
160
|
email: github@philostler.com
|
129
161
|
executables: []
|
@@ -164,7 +196,6 @@ files:
|
|
164
196
|
- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb
|
165
197
|
- spec/rspec/sidekiq/matchers/save_backtrace_spec.rb
|
166
198
|
- spec/rspec/sidekiq/sidekiq_spec.rb
|
167
|
-
- spec/rspec/sidekiq/version_spec.rb
|
168
199
|
- spec/spec_helper.rb
|
169
200
|
- spec/support/factories.rb
|
170
201
|
- spec/support/init.rb
|
@@ -192,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
223
|
- !ruby/object:Gem::Version
|
193
224
|
version: '0'
|
194
225
|
requirements: []
|
195
|
-
|
196
|
-
rubygems_version: 2.4.8
|
226
|
+
rubygems_version: 3.0.3
|
197
227
|
signing_key:
|
198
228
|
specification_version: 4
|
199
229
|
summary: RSpec for Sidekiq
|