resque_spec 0.6.3 → 0.6.4
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.
- data/README.md +10 -2
- data/lib/resque_spec/ext.rb +18 -0
- data/lib/resque_spec/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -5,6 +5,8 @@ A simple RSpec and Cucumber matcher for Resque.enqueue and Resque.enqueue_at
|
|
5
5
|
(from `ResqueScheduler`), loosely based on
|
6
6
|
[http://github.com/justinweiss/resque_unit](http://github.com/justinweiss/resque_unit).
|
7
7
|
|
8
|
+
ResqueSpec will also fire Resque hooks if you are using them. See below.
|
9
|
+
|
8
10
|
This should work with `Resque v1.15.0` and up and `RSpec v2.5.0` and up.
|
9
11
|
|
10
12
|
If you are using `RSpec ~> 1.3.0`, you should use version `~> 0.2.0`. This
|
@@ -181,8 +183,14 @@ You can turn this behavior on by setting `ResqueSpec.inline = true`.
|
|
181
183
|
Hooks
|
182
184
|
-----
|
183
185
|
|
184
|
-
Resque
|
185
|
-
|
186
|
+
Resque provides hooks at different points of the queueing lifecylce. ResqueSpec fires these hooks when appropriate.
|
187
|
+
|
188
|
+
The after enqueue hook is always called when you use `Resque#enqueue`.
|
189
|
+
|
190
|
+
The `perform` hooks: before, around, after, and on failure are fired by
|
191
|
+
ResqueSpec if you are using the `with_resque` helper or set `ResqueSpec.inline = true`.
|
192
|
+
|
193
|
+
Important! `Resque#enqueue_at` does not fire the after enqueue hook (the job has not been queued yet!), but will fire the `perform` hooks if you are using `inline` mode.
|
186
194
|
|
187
195
|
Note on Patches/Pull Requests
|
188
196
|
=============================
|
data/lib/resque_spec/ext.rb
CHANGED
@@ -19,4 +19,22 @@ module Resque
|
|
19
19
|
old_count - ResqueSpec.queues[queue].size
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
def enqueue(klass, *args)
|
24
|
+
if ResqueSpec.inline
|
25
|
+
run_after_enqueue(klass, *args)
|
26
|
+
Job.create(queue_from_class(klass), klass, *args)
|
27
|
+
else
|
28
|
+
Job.create(queue_from_class(klass), klass, *args)
|
29
|
+
run_after_enqueue(klass, *args)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def run_after_enqueue(klass, *args)
|
36
|
+
Plugin.after_enqueue_hooks(klass).each do |hook|
|
37
|
+
klass.send(hook, *args)
|
38
|
+
end
|
39
|
+
end
|
22
40
|
end
|
data/lib/resque_spec/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: resque_spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.6.
|
5
|
+
version: 0.6.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Les Hill
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-21 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|