resque_unit 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/resque_unit/assertions.rb +1 -0
- data/lib/resque_unit/resque.rb +5 -1
- data/test/resque_unit_test.rb +4 -0
- metadata +3 -8
@@ -72,6 +72,7 @@ module ResqueUnit::Assertions
|
|
72
72
|
def matching_jobs(queue, klass, args = nil)
|
73
73
|
queue = Resque.queue(queue) if queue.is_a? Symbol
|
74
74
|
if args # retrieve the elements that match klass and args in the queue
|
75
|
+
args = Resque.normalized_args(args)
|
75
76
|
queue.select {|e| e[:klass] == klass && e[:args] == args}
|
76
77
|
else # if no args were passed, retrieve all queued jobs that match klass
|
77
78
|
queue.select {|e| e[:klass] == klass}
|
data/lib/resque_unit/resque.rb
CHANGED
@@ -74,7 +74,11 @@ module Resque
|
|
74
74
|
queue_name = queue_for(klass)
|
75
75
|
# Behaves like Resque, raise if no queue was specifed
|
76
76
|
raise NoQueueError.new("Jobs must be placed onto a queue.") unless queue_name
|
77
|
-
queue(queue_name) << {:klass => klass, :args =>
|
77
|
+
queue(queue_name) << {:klass => klass, :args => normalized_args(args) }
|
78
|
+
end
|
79
|
+
|
80
|
+
def normalized_args(args)
|
81
|
+
decode(encode(args))
|
78
82
|
end
|
79
83
|
|
80
84
|
# :nodoc:
|
data/test/resque_unit_test.rb
CHANGED
@@ -145,6 +145,10 @@ class ResqueUnitTest < Test::Unit::TestCase
|
|
145
145
|
assert_queued(JobWithArguments, [1, "test", {"symbol"=>"symbol"}])
|
146
146
|
end
|
147
147
|
|
148
|
+
should "pass the assert_queued(job, *args) assertion if the args match using symbols" do
|
149
|
+
assert_queued(JobWithArguments, [1, :test, {:symbol => :symbol}])
|
150
|
+
end
|
151
|
+
|
148
152
|
should "pass the assert_queued(job) assertion with no args passed" do
|
149
153
|
assert_queued(JobWithArguments)
|
150
154
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_unit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 17
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
8
|
+
- 2
|
9
|
+
version: 0.3.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Justin Weiss
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-12-07 00:00:00 -08:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
28
|
segments:
|
31
29
|
- 1
|
32
30
|
- 4
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 3
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
version: "0"
|
@@ -84,7 +81,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
81
|
requirements:
|
85
82
|
- - ">="
|
86
83
|
- !ruby/object:Gem::Version
|
87
|
-
hash: 3
|
88
84
|
segments:
|
89
85
|
- 0
|
90
86
|
version: "0"
|
@@ -93,7 +89,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
89
|
requirements:
|
94
90
|
- - ">="
|
95
91
|
- !ruby/object:Gem::Version
|
96
|
-
hash: 3
|
97
92
|
segments:
|
98
93
|
- 0
|
99
94
|
version: "0"
|