rspec-sidekiq 3.0.3 → 4.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 +43 -0
- data/LICENSE +12 -0
- data/README.md +217 -84
- data/lib/rspec/sidekiq/batch.rb +30 -3
- data/lib/rspec/sidekiq/configuration.rb +13 -2
- data/lib/rspec/sidekiq/matchers/base.rb +262 -0
- data/lib/rspec/sidekiq/matchers/be_delayed.rb +17 -3
- data/lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb +99 -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
- data/lib/rspec-sidekiq.rb +2 -0
- metadata +130 -83
- 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 -37
- data/spec/rspec/sidekiq/batch_spec.rb +0 -77
- 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 -228
- 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 -16
- data/spec/support/test_worker.rb +0 -8
- data/spec/support/test_worker_alternative.rb +0 -8
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Aidan Coyle
|
7
8
|
- Phil Ostler
|
8
|
-
|
9
|
+
- Will Spurgin
|
10
|
+
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date:
|
13
|
+
date: 2023-10-27 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: rspec-core
|
@@ -17,9 +19,20 @@ dependencies:
|
|
17
19
|
- - "~>"
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '3.0'
|
20
|
-
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '3.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rspec-mocks
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
21
34
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.0
|
35
|
+
version: '3.0'
|
23
36
|
type: :runtime
|
24
37
|
prerelease: false
|
25
38
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,149 +40,201 @@ dependencies:
|
|
27
40
|
- - "~>"
|
28
41
|
- !ruby/object:Gem::Version
|
29
42
|
version: '3.0'
|
30
|
-
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rspec-expectations
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
31
48
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.0
|
49
|
+
version: '3.0'
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '3.0'
|
33
57
|
- !ruby/object:Gem::Dependency
|
34
58
|
name: sidekiq
|
35
59
|
requirement: !ruby/object:Gem::Requirement
|
36
60
|
requirements:
|
37
61
|
- - ">="
|
38
62
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
63
|
+
version: '5'
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '8'
|
40
67
|
type: :runtime
|
41
68
|
prerelease: false
|
42
69
|
version_requirements: !ruby/object:Gem::Requirement
|
43
70
|
requirements:
|
44
71
|
- - ">="
|
45
72
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
73
|
+
version: '5'
|
74
|
+
- - "<"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '8'
|
47
77
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
78
|
+
name: pry
|
49
79
|
requirement: !ruby/object:Gem::Requirement
|
50
80
|
requirements:
|
51
|
-
- - "
|
81
|
+
- - ">="
|
52
82
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
83
|
+
version: '0'
|
54
84
|
type: :development
|
55
85
|
prerelease: false
|
56
86
|
version_requirements: !ruby/object:Gem::Requirement
|
57
87
|
requirements:
|
58
|
-
- - "
|
88
|
+
- - ">="
|
59
89
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
90
|
+
version: '0'
|
61
91
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
92
|
+
name: pry-doc
|
63
93
|
requirement: !ruby/object:Gem::Requirement
|
64
94
|
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0.8'
|
68
95
|
- - ">="
|
69
96
|
- !ruby/object:Gem::Version
|
70
|
-
version: 0
|
97
|
+
version: '0'
|
71
98
|
type: :development
|
72
99
|
prerelease: false
|
73
100
|
version_requirements: !ruby/object:Gem::Requirement
|
74
101
|
requirements:
|
75
|
-
- - "
|
102
|
+
- - ">="
|
76
103
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0
|
104
|
+
version: '0'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: pry-nav
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
78
109
|
- - ">="
|
79
110
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0
|
111
|
+
version: '0'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
81
119
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
120
|
+
name: rspec
|
83
121
|
requirement: !ruby/object:Gem::Requirement
|
84
122
|
requirements:
|
85
|
-
- - "
|
123
|
+
- - ">="
|
86
124
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
125
|
+
version: '0'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
- !ruby/object:Gem::Dependency
|
134
|
+
name: coveralls
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
88
137
|
- - ">="
|
89
138
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
139
|
+
version: '0'
|
91
140
|
type: :development
|
92
141
|
prerelease: false
|
93
142
|
version_requirements: !ruby/object:Gem::Requirement
|
94
143
|
requirements:
|
95
|
-
- - "
|
144
|
+
- - ">="
|
96
145
|
- !ruby/object:Gem::Version
|
97
|
-
version: '
|
146
|
+
version: '0'
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: fuubar
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
98
151
|
- - ">="
|
99
152
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
101
161
|
- !ruby/object:Gem::Dependency
|
102
162
|
name: activejob
|
103
163
|
requirement: !ruby/object:Gem::Requirement
|
104
164
|
requirements:
|
105
|
-
- - "~>"
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '4.2'
|
108
165
|
- - ">="
|
109
166
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
167
|
+
version: '0'
|
111
168
|
type: :development
|
112
169
|
prerelease: false
|
113
170
|
version_requirements: !ruby/object:Gem::Requirement
|
114
171
|
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '4.2'
|
118
172
|
- - ">="
|
119
173
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
174
|
+
version: '0'
|
121
175
|
- !ruby/object:Gem::Dependency
|
122
176
|
name: actionmailer
|
123
177
|
requirement: !ruby/object:Gem::Requirement
|
124
178
|
requirements:
|
125
|
-
- - "~>"
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '4.2'
|
128
179
|
- - ">="
|
129
180
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
181
|
+
version: '0'
|
131
182
|
type: :development
|
132
183
|
prerelease: false
|
133
184
|
version_requirements: !ruby/object:Gem::Requirement
|
134
185
|
requirements:
|
135
|
-
- - "~>"
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: '4.2'
|
138
186
|
- - ">="
|
139
187
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
188
|
+
version: '0'
|
141
189
|
- !ruby/object:Gem::Dependency
|
142
190
|
name: activerecord
|
143
191
|
requirement: !ruby/object:Gem::Requirement
|
144
192
|
requirements:
|
145
|
-
- - "
|
193
|
+
- - ">="
|
146
194
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
195
|
+
version: '0'
|
196
|
+
type: :development
|
197
|
+
prerelease: false
|
198
|
+
version_requirements: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
- !ruby/object:Gem::Dependency
|
204
|
+
name: activemodel
|
205
|
+
requirement: !ruby/object:Gem::Requirement
|
206
|
+
requirements:
|
148
207
|
- - ">="
|
149
208
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
209
|
+
version: '0'
|
151
210
|
type: :development
|
152
211
|
prerelease: false
|
153
212
|
version_requirements: !ruby/object:Gem::Requirement
|
154
213
|
requirements:
|
155
|
-
- - "
|
214
|
+
- - ">="
|
156
215
|
- !ruby/object:Gem::Version
|
157
|
-
version: '
|
216
|
+
version: '0'
|
217
|
+
- !ruby/object:Gem::Dependency
|
218
|
+
name: activesupport
|
219
|
+
requirement: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
158
221
|
- - ">="
|
159
222
|
- !ruby/object:Gem::Version
|
160
|
-
version:
|
223
|
+
version: '0'
|
224
|
+
type: :development
|
225
|
+
prerelease: false
|
226
|
+
version_requirements: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
161
231
|
description: Simple testing of Sidekiq jobs via a collection of matchers and helpers
|
162
|
-
email:
|
232
|
+
email:
|
163
233
|
executables: []
|
164
234
|
extensions: []
|
165
235
|
extra_rdoc_files: []
|
166
236
|
files:
|
167
|
-
- ".gitattributes"
|
168
|
-
- ".gitignore"
|
169
|
-
- ".rspec"
|
170
|
-
- ".simplecov"
|
171
237
|
- CHANGES.md
|
172
|
-
- Gemfile
|
173
238
|
- LICENSE
|
174
239
|
- README.md
|
175
240
|
- lib/rspec-sidekiq.rb
|
@@ -178,39 +243,22 @@ files:
|
|
178
243
|
- lib/rspec/sidekiq/helpers.rb
|
179
244
|
- lib/rspec/sidekiq/helpers/within_sidekiq_retries_exhausted_block.rb
|
180
245
|
- lib/rspec/sidekiq/matchers.rb
|
246
|
+
- lib/rspec/sidekiq/matchers/base.rb
|
181
247
|
- lib/rspec/sidekiq/matchers/be_delayed.rb
|
182
248
|
- lib/rspec/sidekiq/matchers/be_expired_in.rb
|
183
249
|
- lib/rspec/sidekiq/matchers/be_processed_in.rb
|
184
250
|
- lib/rspec/sidekiq/matchers/be_retryable.rb
|
185
251
|
- lib/rspec/sidekiq/matchers/be_unique.rb
|
186
|
-
- lib/rspec/sidekiq/matchers/
|
252
|
+
- lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb
|
253
|
+
- lib/rspec/sidekiq/matchers/have_enqueued_sidekiq_job.rb
|
187
254
|
- lib/rspec/sidekiq/matchers/save_backtrace.rb
|
188
255
|
- lib/rspec/sidekiq/sidekiq.rb
|
189
256
|
- lib/rspec/sidekiq/version.rb
|
190
|
-
|
191
|
-
- spec/rspec/sidekiq/batch_spec.rb
|
192
|
-
- spec/rspec/sidekiq/helpers/retries_exhausted_spec.rb
|
193
|
-
- spec/rspec/sidekiq/matchers/be_delayed_spec.rb
|
194
|
-
- spec/rspec/sidekiq/matchers/be_expired_in_spec.rb
|
195
|
-
- spec/rspec/sidekiq/matchers/be_processed_in_spec.rb
|
196
|
-
- spec/rspec/sidekiq/matchers/be_retryable_spec.rb
|
197
|
-
- spec/rspec/sidekiq/matchers/be_unique_spec.rb
|
198
|
-
- spec/rspec/sidekiq/matchers/have_enqueued_job_spec.rb
|
199
|
-
- spec/rspec/sidekiq/matchers/save_backtrace_spec.rb
|
200
|
-
- spec/rspec/sidekiq/sidekiq_spec.rb
|
201
|
-
- spec/spec_helper.rb
|
202
|
-
- spec/support/factories.rb
|
203
|
-
- spec/support/init.rb
|
204
|
-
- spec/support/test_action_mailer.rb
|
205
|
-
- spec/support/test_job.rb
|
206
|
-
- spec/support/test_resource.rb
|
207
|
-
- spec/support/test_worker.rb
|
208
|
-
- spec/support/test_worker_alternative.rb
|
209
|
-
homepage: http://github.com/philostler/rspec-sidekiq
|
257
|
+
homepage: http://github.com/wspurgin/rspec-sidekiq
|
210
258
|
licenses:
|
211
259
|
- MIT
|
212
260
|
metadata: {}
|
213
|
-
post_install_message:
|
261
|
+
post_install_message:
|
214
262
|
rdoc_options: []
|
215
263
|
require_paths:
|
216
264
|
- lib
|
@@ -218,16 +266,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
266
|
requirements:
|
219
267
|
- - ">="
|
220
268
|
- !ruby/object:Gem::Version
|
221
|
-
version: '
|
269
|
+
version: '2.7'
|
222
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
271
|
requirements:
|
224
272
|
- - ">="
|
225
273
|
- !ruby/object:Gem::Version
|
226
274
|
version: '0'
|
227
275
|
requirements: []
|
228
|
-
|
229
|
-
|
230
|
-
signing_key:
|
276
|
+
rubygems_version: 3.3.26
|
277
|
+
signing_key:
|
231
278
|
specification_version: 4
|
232
279
|
summary: RSpec for Sidekiq
|
233
280
|
test_files: []
|
data/.gitattributes
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# Auto detect text files and perform LF normalization
|
2
|
-
* text=auto
|
3
|
-
|
4
|
-
# Custom for Visual Studio
|
5
|
-
*.cs diff=csharp
|
6
|
-
*.sln merge=union
|
7
|
-
*.csproj merge=union
|
8
|
-
*.vbproj merge=union
|
9
|
-
*.fsproj merge=union
|
10
|
-
*.dbproj merge=union
|
11
|
-
|
12
|
-
# Standard to msysgit
|
13
|
-
*.doc diff=astextplain
|
14
|
-
*.DOC diff=astextplain
|
15
|
-
*.docx diff=astextplain
|
16
|
-
*.DOCX diff=astextplain
|
17
|
-
*.dot diff=astextplain
|
18
|
-
*.DOT diff=astextplain
|
19
|
-
*.pdf diff=astextplain
|
20
|
-
*.PDF diff=astextplain
|
21
|
-
*.rtf diff=astextplain
|
22
|
-
*.RTF diff=astextplain
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.simplecov
DELETED
data/Gemfile
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Sidekiq
|
3
|
-
module Matchers
|
4
|
-
def have_enqueued_sidekiq_job(*expected_arguments)
|
5
|
-
HaveEnqueuedJob.new expected_arguments
|
6
|
-
end
|
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'].blank?
|
29
|
-
value.to_time.to_s == Time.at(job['at']).to_s
|
30
|
-
end
|
31
|
-
|
32
|
-
def in_evaluator(value)
|
33
|
-
return false if job['at'].blank?
|
34
|
-
(Time.now + value).to_s == Time.at(job['at']).to_s
|
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
|
-
|
89
|
-
class HaveEnqueuedJob
|
90
|
-
attr_reader :klass, :expected_arguments, :actual_arguments, :expected_options, :actual_options
|
91
|
-
|
92
|
-
def initialize(expected_arguments)
|
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
|
112
|
-
end
|
113
|
-
|
114
|
-
def description
|
115
|
-
"have an enqueued #{klass} job with arguments #{expected_arguments}"
|
116
|
-
end
|
117
|
-
|
118
|
-
def failure_message
|
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")
|
126
|
-
end
|
127
|
-
|
128
|
-
def failure_message_when_negated
|
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")
|
133
|
-
end
|
134
|
-
|
135
|
-
private
|
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
|
-
|
144
|
-
def unwrapped_job_arguments(jobs)
|
145
|
-
if jobs.is_a? Hash
|
146
|
-
jobs.values.flatten.map do |job|
|
147
|
-
map_arguments(job)
|
148
|
-
end
|
149
|
-
else
|
150
|
-
map_arguments(jobs)
|
151
|
-
end.map { |job| job.flatten }
|
152
|
-
end
|
153
|
-
|
154
|
-
def map_arguments(job)
|
155
|
-
args = job_arguments(job) || job
|
156
|
-
if args.respond_to?(:any?) && args.any? { |e| e.is_a? Hash }
|
157
|
-
args.map { |a| map_arguments(a) }
|
158
|
-
else
|
159
|
-
args
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def job_arguments(hash)
|
164
|
-
hash['arguments'] || hash['args'] if hash.is_a? Hash
|
165
|
-
end
|
166
|
-
|
167
|
-
def normalize_arguments(args)
|
168
|
-
if args.is_a?(Array)
|
169
|
-
args.map{ |x| normalize_arguments(x) }
|
170
|
-
elsif args.is_a?(Hash)
|
171
|
-
args.each_with_object({}) do |(key, value), hash|
|
172
|
-
hash[key.to_s] = normalize_arguments(value)
|
173
|
-
end
|
174
|
-
elsif args.is_a?(Symbol)
|
175
|
-
args.to_s
|
176
|
-
else
|
177
|
-
args
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
data/rspec-sidekiq.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require File.expand_path('../lib/rspec/sidekiq/version', __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = 'rspec-sidekiq'
|
5
|
-
s.version = RSpec::Sidekiq::VERSION
|
6
|
-
s.platform = Gem::Platform::RUBY
|
7
|
-
s.author = 'Phil Ostler'
|
8
|
-
s.email = 'github@philostler.com'
|
9
|
-
s.homepage = 'http://github.com/philostler/rspec-sidekiq'
|
10
|
-
s.summary = 'RSpec for Sidekiq'
|
11
|
-
s.description = 'Simple testing of Sidekiq jobs via a collection of matchers and helpers'
|
12
|
-
s.license = 'MIT'
|
13
|
-
|
14
|
-
s.add_dependency 'rspec-core', '~> 3.0', '>= 3.0.0'
|
15
|
-
s.add_dependency 'sidekiq', '>= 2.4.0'
|
16
|
-
|
17
|
-
s.add_development_dependency 'rspec', '~> 3.0'
|
18
|
-
s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8.0'
|
19
|
-
s.add_development_dependency 'fuubar', '~> 2.0', '>= 2.0.0'
|
20
|
-
s.add_development_dependency 'activejob', '~> 4.2', '>= 4.0.0'
|
21
|
-
s.add_development_dependency 'actionmailer', '~> 4.2', '>= 4.0.0'
|
22
|
-
s.add_development_dependency 'activerecord', '~> 4.2', '>= 4.0.0'
|
23
|
-
|
24
|
-
|
25
|
-
s.files = Dir['.gitattributes'] +
|
26
|
-
Dir['.gitignore'] +
|
27
|
-
Dir['.rspec'] +
|
28
|
-
Dir['.simplecov'] +
|
29
|
-
Dir['.travis'] +
|
30
|
-
Dir['CHANGES.md'] +
|
31
|
-
Dir['Gemfile'] +
|
32
|
-
Dir['LICENSE'] +
|
33
|
-
Dir['README.md'] +
|
34
|
-
Dir['rspec-sidekiq.gemspec'] +
|
35
|
-
Dir['**/*.rb']
|
36
|
-
s.require_paths = ['lib']
|
37
|
-
end
|