rspec-sidekiq_pro 1.4.0 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55d1575abf29d7fc9af11422d7c1e871978c33ac2ea7a4100494a306123f6a7e
4
- data.tar.gz: a059479eee7b6c8ea39a5190906ed942f952f4522a9d1696aff18163cde8c707
3
+ metadata.gz: 32a3e043a422ccb18bf8aaab5550b7ee6e106e2497d655a3b6733314628ab857
4
+ data.tar.gz: 4522464be86476fbbe612364071a479ad13069782cb155dc4a465e4c755f83f2
5
5
  SHA512:
6
- metadata.gz: c489d81fd32184a7c6039be5bb3040affc61c6326d9889f7216b17ee6d9a4e31995286652f3370b48aeefe866e30a1b0fcde061f53094a983388ae590813f8c1
7
- data.tar.gz: 4fb200762bbfe3b850269296d8ae9277d11aa88cc5b16d22c202bad79289e97b4a01e0e8ed337a1fbc3ef1757c745f1a1772aa76c5eaee6db42505188bf8559a
6
+ metadata.gz: a158ae5fbf0c9ec357dde35da5ec22fea264c9e8d628f5fa3e963f87fc578037a1d462c8a165fa08ab11afb55b45c1695d88f25fcee4ff6d0c78cc8f4dbcd8ef
7
+ data.tar.gz: afa40423e976cf54ab957ffb33c41422d113123e8783fc2f867e6933409b7143c7e77856e8de3cb1a0f2aeb04a27bc9555e748304dbf978165208030e42e8b20
data/README.md CHANGED
@@ -53,6 +53,7 @@ end
53
53
  Both matchers provide the same chainable methods:
54
54
 
55
55
  * `.with`
56
+ * `.without_argument`
56
57
  * `.once`
57
58
  * `.twice`
58
59
  * `.exactly(n).times`
@@ -8,6 +8,7 @@ module RSpec
8
8
 
9
9
  attr_reader :worker_class,
10
10
  :expected_arguments,
11
+ :expected_without_argument,
11
12
  :expected_interval,
12
13
  :expected_timestamp,
13
14
  :expected_schedule,
@@ -21,6 +22,8 @@ module RSpec
21
22
  :actual_jobs
22
23
 
23
24
  def with(*expected_arguments, &block)
25
+ raise "setting expecations with both `with` and `without_argument` is not supported" if @expected_without_argument
26
+
24
27
  if block
25
28
  raise ArgumentError, "setting block to `with` is not supported for this matcher" if supports_value_expectations?
26
29
  raise ArgumentError, "setting arguments and block together in `with` is not supported" if expected_arguments.any?
@@ -32,6 +35,13 @@ module RSpec
32
35
  self
33
36
  end
34
37
 
38
+ def without_argument
39
+ raise "setting expecations with both `with` and `without_argument` is not supported" if @expected_arguments
40
+
41
+ @expected_without_argument = true
42
+ self
43
+ end
44
+
35
45
  def in(interval)
36
46
  raise "setting expecations with both `at` and `in` is not supported" if @expected_timestamp
37
47
 
@@ -172,7 +182,9 @@ module RSpec
172
182
  description += " less than #{expected_less_count} times"
173
183
  end
174
184
 
175
- if expected_arguments.is_a?(Proc)
185
+ if expected_without_argument
186
+ description += " without arguments"
187
+ elsif expected_arguments.is_a?(Proc)
176
188
  description += " with some arguments"
177
189
  elsif expected_arguments
178
190
  description += " with arguments #{expected_arguments}"
@@ -187,7 +199,7 @@ module RSpec
187
199
  message << "" if message.any?
188
200
  message << actual_jobs_size_in_failure_message
189
201
 
190
- if expected_arguments || expected_schedule || expected_without_batch || expected_batch
202
+ if expected_arguments || expected_without_argument || expected_schedule || expected_without_batch || expected_batch
191
203
  message[-1] = "#{message[-1]}:"
192
204
  message += actual_jobs_details_in_failure_message
193
205
  end
@@ -213,6 +225,7 @@ module RSpec
213
225
  message << " more than: #{expected_more_count} time(s)" if expected_more_count
214
226
  message << " less than: #{expected_less_count} time(s)" if expected_less_count
215
227
  message << " arguments: #{expected_arguments}" if expected_arguments
228
+ message << " arguments: no arguments" if expected_without_argument
216
229
  message << " in: #{expected_interval_output}" if expected_interval
217
230
  message << " at: #{expected_timestamp}" if expected_timestamp
218
231
  message << " batch: #{output_batch(expected_batch)}" if expected_batch
@@ -222,7 +235,8 @@ module RSpec
222
235
 
223
236
  def job_details_in_failure_message(job)
224
237
  message = []
225
- message << " arguments: #{job["args"]}" if expected_arguments
238
+ message << " arguments: #{job["args"]}" if (expected_arguments || expected_without_argument) && job["args"].any?
239
+ message << " arguments: no arguments" if (expected_arguments || expected_without_argument) && job["args"].empty?
226
240
  message << " at: #{output_schedule(job["at"])}" if expected_schedule && job["at"]
227
241
  message << " at: no schedule" if expected_schedule && !job["at"]
228
242
  message << " batch: #{output_batch(job["bid"])}" if (expected_without_batch || expected_batch) && job["bid"]
@@ -274,6 +288,7 @@ module RSpec
274
288
  def filter_jobs(jobs)
275
289
  jobs.select do |job|
276
290
  next if expected_arguments && !values_match?(expected_arguments, job["args"])
291
+ next if expected_without_argument && job["args"].any?
277
292
  next if expected_schedule && !values_match?(expected_schedule.to_i, job["at"].to_i)
278
293
  next if expected_without_batch && job["bid"]
279
294
  next if expected_batch && !batch_match?(expected_batch, job["bid"])
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module SidekiqPro
5
- VERSION = "1.4.0"
5
+ VERSION = "1.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sidekiq_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savater Sebastien