rspec-sidekiq_pro 1.3.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: 9c17791f8aa93dfb4980ced725dc7469ffb056be113a035fc1586ef278116d83
4
- data.tar.gz: 1aa9429f684ee980239144b919c3dc5912bac6a5bbb4c4958fd53c6a0f1f08b4
3
+ metadata.gz: 32a3e043a422ccb18bf8aaab5550b7ee6e106e2497d655a3b6733314628ab857
4
+ data.tar.gz: 4522464be86476fbbe612364071a479ad13069782cb155dc4a465e4c755f83f2
5
5
  SHA512:
6
- metadata.gz: b99e17cb692da23642dc8f988f339cf419783207143bd6871f285ad30a96a34ea8a69115924c657aecc96decd48c2fda88d21ad106e90c1896bed3a797e91b00
7
- data.tar.gz: 6091324c106b4472dcd44a6b17ced626d8a4431d444857505851caae2eb4e398f53ca64bb2d27d7ecd42af22002646f2cc0a93c3c0fdcf25649f85a34d3fcf18
6
+ metadata.gz: a158ae5fbf0c9ec357dde35da5ec22fea264c9e8d628f5fa3e963f87fc578037a1d462c8a165fa08ab11afb55b45c1695d88f25fcee4ff6d0c78cc8f4dbcd8ef
7
+ data.tar.gz: afa40423e976cf54ab957ffb33c41422d113123e8783fc2f867e6933409b7143c7e77856e8de3cb1a0f2aeb04a27bc9555e748304dbf978165208030e42e8b20
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2022 Savater Sebastien
1
+ Copyright (c) 2022-2026 Savater Sebastien
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -14,9 +14,9 @@ bundle add rspec-sidekiq_pro --group=test
14
14
 
15
15
  ### Configuration
16
16
 
17
- `rspec/sidekiq_pro` requires `sidekiq/testing` by default so there is no need to include it.
18
-
19
- It also means that Sidekiq in set to `fake` mode by default. Take a look at [Sidekiq wiki](https://github.com/mperham/sidekiq/wiki/Testing) for more details.
17
+ Sidekiq testing mode is set to `fake` by default by the gem.
18
+ You don't need to set it (or require `sidekiq/testing` prior to Sidekiq 8.1).
19
+ Take a look at [Sidekiq wiki](https://github.com/mperham/sidekiq/wiki/Testing) for more details.
20
20
 
21
21
  If you wish to start each spec without enqueued jobs or batches:
22
22
 
@@ -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`
@@ -207,6 +208,12 @@ bundle exec rubocop
207
208
  bundle exec standardrb
208
209
  ```
209
210
 
211
+ To run RSpec against various version of Sidekiq dependencies:
212
+ ```bash
213
+ bundle exec appraisal install
214
+ bundle exec appraisal rspec
215
+ ```
216
+
210
217
  All of them can be run with:
211
218
 
212
219
  ```bash
@@ -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.3.0"
5
+ VERSION = "1.5.0"
6
6
  end
7
7
  end
@@ -3,12 +3,17 @@
3
3
  require "rspec"
4
4
  require "sidekiq"
5
5
  require "sidekiq-pro"
6
- require "sidekiq/testing"
7
6
  require "active_support/duration"
8
7
  require "active_support/core_ext/module/delegation"
9
8
  require "rspec/sidekiq_pro/matchers"
10
9
  require "rspec/sidekiq_pro/batches"
11
10
 
11
+ if Gem::Version.new(Sidekiq::VERSION) < "8.1"
12
+ require "sidekiq/testing"
13
+ else
14
+ Sidekiq.testing!(:fake)
15
+ end
16
+
12
17
  RSpec.configure do |config|
13
18
  config.include RSpec::SidekiqPro::Matchers
14
19
  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.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Savater Sebastien
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.6.7
133
+ rubygems_version: 4.0.3
134
134
  specification_version: 4
135
135
  summary: A collection of RSpec matchers for Sidekiq Pro
136
136
  test_files: []