rspec-sidekiq 4.0.2 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +6 -0
- data/README.md +19 -3
- data/lib/rspec/sidekiq/matchers/base.rb +7 -1
- data/lib/rspec/sidekiq/matchers/enqueue_sidekiq_job.rb +13 -1
- data/lib/rspec/sidekiq/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4f0ece401056914cf478dc4657d19aad569156ebf40ee29ee85c36fc430cfc3
|
4
|
+
data.tar.gz: 858c2c49ae54497a5201eab4cb3d9179fbe21a1684b11663719dfd17dd198cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 831dfa10d07623e001f2253072b6d8e5311a0d887661421ba3eb914fce8f5020b73e5c7bda02264ebf4be6b6f23c2b02f8082a149d7ff5836895525ae61d697c
|
7
|
+
data.tar.gz: fda99d4e3bd9b43fb55ed60e96f77fd0ca54156bc6dcc42df3f1d2fb9323fff9fc63f5495a595766e937d0214fff10736ef18b9b468fccf4b97b91b2aae5e296
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -75,11 +75,17 @@ expect { AwesomeJob.perform_at(specific_time, "Awesome!") }.to(
|
|
75
75
|
.on("default")
|
76
76
|
.at(specific_time)
|
77
77
|
)
|
78
|
+
|
79
|
+
# Also composable
|
80
|
+
expect do
|
81
|
+
AwesomeJob.perform_async
|
82
|
+
OtherJob.perform_async
|
83
|
+
end.to enqueue_sidekiq_job(AwesomeJob).and enqueue_sidekiq_job(OtherJob)
|
78
84
|
```
|
79
85
|
|
80
86
|
### have_enqueued_sidekiq_job
|
81
|
-
|
82
|
-
arguments
|
87
|
+
|
88
|
+
Describes that there should be an enqueued job with the **specified arguments**
|
83
89
|
|
84
90
|
```ruby
|
85
91
|
AwesomeJob.perform_async 'Awesome', true
|
@@ -95,11 +101,14 @@ AwesomeJob.perform_async({"something" => "Awesome", "extra" => "stuff"})
|
|
95
101
|
expect(AwesomeJob).to have_enqueued_sidekiq_job(hash_including("something" => "Awesome"))
|
96
102
|
expect(AwesomeJob).to have_enqueued_sidekiq_job(any_args)
|
97
103
|
expect(AwesomeJob).to have_enqueued_sidekiq_job(hash_excluding("bad_stuff" => anything))
|
104
|
+
|
105
|
+
# composable as well
|
106
|
+
expect(AwesomeJob).to have_enqueued_sidekiq_job(any_args).and have_enqueued_sidekiq_job(hash_including("something" => "Awesome"))
|
98
107
|
```
|
99
108
|
|
100
109
|
#### Testing scheduled jobs
|
101
110
|
|
102
|
-
*Use chainable matchers `#at` and `#
|
111
|
+
*Use chainable matchers `#at`, `#in` and `#immediately`*
|
103
112
|
|
104
113
|
```ruby
|
105
114
|
time = 5.minutes.from_now
|
@@ -113,6 +122,13 @@ AwesomeJob.perform_in 5.minutes, 'Awesome', true
|
|
113
122
|
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).in(5.minutes)
|
114
123
|
```
|
115
124
|
|
125
|
+
```ruby
|
126
|
+
# Job scheduled for a date in the past are enqueued immediately.
|
127
|
+
AwesomeJob.perform_later 5.minutes.ago, 'Awesome', true # equivalent to: AwesomeJob.perform_async 'Awesome', true
|
128
|
+
# test with...
|
129
|
+
expect(AwesomeJob).to have_enqueued_sidekiq_job('Awesome', true).immediately
|
130
|
+
```
|
131
|
+
|
116
132
|
#### Testing queue set for job
|
117
133
|
|
118
134
|
Use the chainable `#on` matcher
|
@@ -16,7 +16,7 @@ module RSpec
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def at_evaluator(value)
|
19
|
-
return
|
19
|
+
return value.nil? if job["at"].to_s.empty?
|
20
20
|
value == Time.at(job["at"]).to_i
|
21
21
|
end
|
22
22
|
|
@@ -162,6 +162,7 @@ module RSpec
|
|
162
162
|
# @api private
|
163
163
|
class Base
|
164
164
|
include RSpec::Mocks::ArgumentMatchers
|
165
|
+
include RSpec::Matchers::Composable
|
165
166
|
|
166
167
|
attr_reader :expected_arguments, :expected_options, :klass, :actual_jobs
|
167
168
|
|
@@ -185,6 +186,11 @@ module RSpec
|
|
185
186
|
self
|
186
187
|
end
|
187
188
|
|
189
|
+
def immediately
|
190
|
+
@expected_options["at"] = nil
|
191
|
+
self
|
192
|
+
end
|
193
|
+
|
188
194
|
def on(queue)
|
189
195
|
@expected_options["queue"] = queue
|
190
196
|
self
|
@@ -56,7 +56,8 @@ module RSpec
|
|
56
56
|
#
|
57
57
|
# Passes if a Job is enqueued as the result of a block. Chainable `with`
|
58
58
|
# for arguments, `on` for queue, `at` for queued for a specific time, and
|
59
|
-
# `in` for a specific interval delay to being queued
|
59
|
+
# `in` for a specific interval delay to being queued, `immediately` for
|
60
|
+
# queued without delay.
|
60
61
|
#
|
61
62
|
# @example
|
62
63
|
#
|
@@ -79,6 +80,17 @@ module RSpec
|
|
79
80
|
# freeze_time do
|
80
81
|
# expect { AwesomeJob.perform_in(1.hour) }.to enqueue_sidekiq_job.in(1.hour)
|
81
82
|
# end
|
83
|
+
#
|
84
|
+
# # Without any delay
|
85
|
+
# expect { AwesomeJob.perform_async }.to enqueue_sidekiq_job.immediately
|
86
|
+
# expect { AwesomeJob.perform_at(1.hour.ago) }.to enqueue_sidekiq_job.immediately
|
87
|
+
#
|
88
|
+
# ## Composable
|
89
|
+
#
|
90
|
+
# expect do
|
91
|
+
# AwesomeJob.perform_async
|
92
|
+
# OtherJob.perform_async
|
93
|
+
# end.to enqueue_sidekiq_job(AwesomeJob).and enqueue_sidekiq_job(OtherJob)
|
82
94
|
def enqueue_sidekiq_job(job_class = nil)
|
83
95
|
EnqueueSidekiqJob.new(job_class)
|
84
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aidan Coyle
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-10-27 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec-core
|
@@ -266,7 +266,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
266
|
requirements:
|
267
267
|
- - ">="
|
268
268
|
- !ruby/object:Gem::Version
|
269
|
-
version: '
|
269
|
+
version: '2.7'
|
270
270
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
271
|
requirements:
|
272
272
|
- - ">="
|