resque_unit 0.3.6 → 0.4.8

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1aad0f765a2b78da6d5f17cdbf2f5646066d8b8d
4
+ data.tar.gz: c694a2f46b3ec5892f7a83ebfae9d734dd0371ec
5
+ SHA512:
6
+ metadata.gz: 812552beeb3b8c3de00be72b6c13b8dfc4fd2808df1114f308c3eb5aaba2635108d58d9583c5a8c879248b91b716c0bf21c38fad6b2d1453a0405c272daa3f3b
7
+ data.tar.gz: 97110758541b5c3335906743fdd0dbfd2f1514106ec90ea98dbb9149bef0f86b0932974cc2ed2455d9ea119fffae551aaf9764302ab64101195f4ae3977dec8a
@@ -21,9 +21,9 @@ module ResqueUnit::Assertions
21
21
  queue = if block_given?
22
22
  snapshot = Resque.size(queue_name)
23
23
  yield
24
- Resque.queue(queue_name)[snapshot..-1]
24
+ Resque.all(queue_name)[snapshot..-1]
25
25
  else
26
- Resque.queue(queue_name)
26
+ Resque.all(queue_name)
27
27
  end
28
28
 
29
29
  assert_with_custom_message(!in_queue?(queue, klass, args),
@@ -43,9 +43,9 @@ module ResqueUnit::Assertions
43
43
  queue = if block_given?
44
44
  snapshot = Resque.size(queue_name)
45
45
  yield
46
- Resque.queue(queue_name)[snapshot..-1]
46
+ Resque.all(queue_name)[snapshot..-1]
47
47
  else
48
- Resque.queue(queue_name)
48
+ Resque.all(queue_name)
49
49
  end
50
50
 
51
51
  assert_with_custom_message(in_queue?(queue, klass, args),
@@ -74,13 +74,8 @@ module ResqueUnit::Assertions
74
74
  end
75
75
 
76
76
  def matching_jobs(queue, klass, args = nil)
77
- queue = Resque.queue(queue) if queue.is_a? Symbol
78
- if args # retrieve the elements that match klass and args in the queue
79
- args = Resque.normalized_args(args)
80
- queue.select {|e| e[:klass] == klass && e[:args] == args}
81
- else # if no args were passed, retrieve all queued jobs that match klass
82
- queue.select {|e| e[:klass] == klass}
83
- end
77
+ normalized_args = Resque.decode(Resque.encode(args)) if args
78
+ queue.select {|e| e["class"] == klass.to_s && (!args || e["args"] == normalized_args )}
84
79
  end
85
80
 
86
81
  end
@@ -1,4 +1,4 @@
1
- module Resque
1
+ module ResqueUnit
2
2
  module Helpers
3
3
  # Given a Ruby object, returns a string suitable for storage in a
4
4
  # queue.
@@ -13,7 +13,7 @@ module Resque
13
13
  # Given a string, returns a Ruby object.
14
14
  def decode(object)
15
15
  return unless object
16
-
16
+
17
17
  if defined? Yajl
18
18
  begin
19
19
  Yajl::Parser.parse(object, :check_utf8 => false)
@@ -51,6 +51,11 @@ unless defined?(Resque::Plugin)
51
51
  def after_enqueue_hooks(job)
52
52
  job.methods.grep(/^after_enqueue/).sort
53
53
  end
54
+
55
+ # Given an object, returns a list `before_enqueue` hook names.
56
+ def before_enqueue_hooks(job)
57
+ job.methods.grep(/^before_enqueue/).sort
58
+ end
54
59
  end
55
60
  end
56
61
 
@@ -62,4 +67,4 @@ unless defined?(Resque::Job::DontPerform)
62
67
  DontPerform = Class.new(StandardError)
63
68
  end
64
69
  end
65
- end
70
+ end
@@ -1,7 +1,7 @@
1
1
  # The fake Resque class. This needs to be loaded after the real Resque
2
2
  # for the assertions in +ResqueUnit::Assertions+ to work.
3
3
  module Resque
4
- include Helpers
4
+ include ResqueUnit::Helpers
5
5
  extend self
6
6
 
7
7
  # Resets all the queues to the empty state. This should be called in
@@ -24,13 +24,42 @@ module Resque
24
24
  end
25
25
 
26
26
  # Returns an array of all the jobs that have been queued. Each
27
- # element is of the form +{:klass => klass, :args => args}+ where
27
+ # element is of the form +{"class" => klass, "args" => args}+ where
28
28
  # +klass+ is the job's class and +args+ is an array of the arguments
29
29
  # passed to the job.
30
30
  def queue(queue_name)
31
31
  queues[queue_name]
32
32
  end
33
33
 
34
+ # Return an array of all jobs' payloads for queue
35
+ # Elements are decoded
36
+ def all(queue_name)
37
+ result = list_range(queue_name, 0, size(queue_name))
38
+ result.is_a?(Array) ? result : [ result ]
39
+ end
40
+
41
+ # Returns an array of jobs' payloads for queue.
42
+ #
43
+ # start and count should be integer and can be used for pagination.
44
+ # start is the item to begin, count is how many items to return.
45
+ #
46
+ # To get the 3rd page of a 30 item, paginatied list one would use:
47
+ # Resque.peek('my_list', 59, 30)
48
+ def peek(queue_name, start = 0, count = 1)
49
+ list_range(queue_name, start, count)
50
+ end
51
+
52
+ # Gets a range of jobs' payloads from queue.
53
+ # Returns single element if count equal 1
54
+ # Elements are decoded
55
+ def list_range(key, start = 0, count = 1)
56
+ data = if count == 1
57
+ decode(queues[key][start])
58
+ else
59
+ (queues[key][start...start + count] || []).map { |entry| decode(entry) }
60
+ end
61
+ end
62
+
34
63
  # Yes, all Resque hooks!
35
64
  def enable_hooks!
36
65
  @hooks_enabled = true
@@ -42,25 +71,25 @@ module Resque
42
71
 
43
72
  # Executes all jobs in all queues in an undefined order.
44
73
  def run!
45
- old_queue = @queue.dup
46
- self.reset!
47
-
48
- old_queue.each do |k, v|
49
- while job = v.shift
50
- @hooks_enabled ? perform_with_hooks(job) : perform_without_hooks(job)
51
- end
74
+ payloads = []
75
+ @queue.each do |queue_name, queue|
76
+ payloads.concat queue.slice!(0, queue.size)
52
77
  end
78
+ exec_payloads payloads.shuffle
53
79
  end
54
80
 
55
- # Executes all jobs in the given queue in an undefined order.
56
- def run_for!(queue_name)
57
- jobs = self.queue(queue_name)
58
- self.reset!(queue_name)
81
+ def run_for!(queue_name, limit=false)
82
+ queue = @queue[queue_name]
83
+ exec_payloads queue.slice!(0, ( limit ? limit : queue.size) ).shuffle
84
+ end
59
85
 
60
- while job = jobs.shift
61
- @hooks_enabled ? perform_with_hooks(job) : perform_without_hooks(job)
86
+ def exec_payloads(raw_payloads)
87
+ raw_payloads.each do |raw_payload|
88
+ job_payload = decode(raw_payload)
89
+ @hooks_enabled ? perform_with_hooks(job_payload) : perform_without_hooks(job_payload)
62
90
  end
63
91
  end
92
+ private :exec_payloads
64
93
 
65
94
  # 1. Execute all jobs in all queues in an undefined order,
66
95
  # 2. Check if new jobs were announced, and execute them.
@@ -80,20 +109,21 @@ module Resque
80
109
 
81
110
  # :nodoc:
82
111
  def enqueue(klass, *args)
83
- queue_name = queue_for(klass)
84
- # Behaves like Resque, raise if no queue was specifed
85
- raise NoQueueError.new("Jobs must be placed onto a queue.") unless queue_name
86
- enqueue_unit(queue_name, {:klass => klass, :args => normalized_args(args) })
112
+ enqueue_to( queue_for(klass), klass, *args)
87
113
  end
88
114
 
89
- def normalized_args(args)
90
- decode(encode(args))
115
+ # :nodoc:
116
+ def enqueue_to( queue_name, klass, *args )
117
+ # Behaves like Resque, raise if no queue was specifed
118
+ raise NoQueueError.new("Jobs must be placed onto a queue.") unless queue_name
119
+ enqueue_unit(queue_name, {"class" => klass.to_s, "args" => args })
91
120
  end
92
121
 
93
122
  # :nodoc:
94
123
  def queue_for(klass)
95
124
  klass.instance_variable_get(:@queue) || (klass.respond_to?(:queue) && klass.queue)
96
125
  end
126
+ alias :queue_from_class :queue_for
97
127
 
98
128
  # :nodoc:
99
129
  def empty_queues?
@@ -103,33 +133,41 @@ module Resque
103
133
  end
104
134
 
105
135
  def enqueue_unit(queue_name, hash)
106
- queue(queue_name) << hash
136
+ klass = constantize(hash["class"])
137
+ if @hooks_enabled
138
+ before_hooks = Plugin.before_enqueue_hooks(klass).map do |hook|
139
+ klass.send(hook, *hash["args"])
140
+ end
141
+ return nil if before_hooks.any? { |result| result == false }
142
+ end
143
+ queue(queue_name) << encode(hash)
107
144
  if @hooks_enabled
108
- Plugin.after_enqueue_hooks(hash[:klass]).each do |hook|
109
- hash[:klass].send(hook, *hash[:args])
145
+ Plugin.after_enqueue_hooks(klass).each do |hook|
146
+ klass.send(hook, *hash["args"])
110
147
  end
111
148
  end
112
149
  queue(queue_name).size
113
150
  end
114
151
 
115
152
  # Call perform on the job class
116
- def perform_without_hooks(job)
117
- job[:klass].perform(*job[:args])
153
+ def perform_without_hooks(job_payload)
154
+ constantize(job_payload["class"]).perform(*job_payload["args"])
118
155
  end
119
156
 
120
157
  # Call perform on the job class, and adds support for Resque hooks.
121
- def perform_with_hooks(job)
122
- before_hooks = Resque::Plugin.before_hooks(job[:klass])
123
- around_hooks = Resque::Plugin.around_hooks(job[:klass])
124
- after_hooks = Resque::Plugin.after_hooks(job[:klass])
125
- failure_hooks = Resque::Plugin.failure_hooks(job[:klass])
158
+ def perform_with_hooks(job_payload)
159
+ job_class = constantize(job_payload["class"])
160
+ before_hooks = Resque::Plugin.before_hooks(job_class)
161
+ around_hooks = Resque::Plugin.around_hooks(job_class)
162
+ after_hooks = Resque::Plugin.after_hooks(job_class)
163
+ failure_hooks = Resque::Plugin.failure_hooks(job_class)
126
164
 
127
165
  begin
128
166
  # Execute before_perform hook. Abort the job gracefully if
129
167
  # Resque::DontPerform is raised.
130
168
  begin
131
169
  before_hooks.each do |hook|
132
- job[:klass].send(hook, *job[:args])
170
+ job_class.send(hook, *job_payload["args"])
133
171
  end
134
172
  rescue Resque::Job::DontPerform
135
173
  return false
@@ -137,7 +175,7 @@ module Resque
137
175
 
138
176
  # Execute the job. Do it in an around_perform hook if available.
139
177
  if around_hooks.empty?
140
- perform_without_hooks(job)
178
+ perform_without_hooks(job_payload)
141
179
  job_was_performed = true
142
180
  else
143
181
  # We want to nest all around_perform plugins, with the last one
@@ -145,12 +183,12 @@ module Resque
145
183
  stack = around_hooks.reverse.inject(nil) do |last_hook, hook|
146
184
  if last_hook
147
185
  lambda do
148
- job[:klass].send(hook, *job[:args]) { last_hook.call }
186
+ job_class.send(hook, *job_payload["args"]) { last_hook.call }
149
187
  end
150
188
  else
151
189
  lambda do
152
- job[:klass].send(hook, *job[:args]) do
153
- result = perform_without_hooks(job)
190
+ job_class.send(hook, *job_payload["args"]) do
191
+ result = perform_without_hooks(job_payload)
154
192
  job_was_performed = true
155
193
  result
156
194
  end
@@ -162,7 +200,7 @@ module Resque
162
200
 
163
201
  # Execute after_perform hook
164
202
  after_hooks.each do |hook|
165
- job[:klass].send(hook, *job[:args])
203
+ job_class.send(hook, *job_payload["args"])
166
204
  end
167
205
 
168
206
  # Return true if the job was performed
@@ -170,16 +208,16 @@ module Resque
170
208
 
171
209
  # If an exception occurs during the job execution, look for an
172
210
  # on_failure hook then re-raise.
173
- rescue => e
174
- failure_hooks.each { |hook| job[:klass].send(hook, e, *job[:args]) }
211
+ rescue Object => e
212
+ failure_hooks.each { |hook| job_class.send(hook, e, *job_payload["args"]) }
175
213
  raise e
176
214
  end
177
215
  end
178
216
 
179
217
  class Job
180
- extend Helpers
218
+ extend ResqueUnit::Helpers
181
219
  def self.create(queue, klass_name, *args)
182
- Resque.enqueue_unit(queue, {:klass => constantize(klass_name), :args => decode(encode(args))})
220
+ Resque.enqueue_unit(queue, {"class" => constantize(klass_name).to_s, "args" => args})
183
221
  end
184
222
  end
185
223
 
@@ -1,5 +1,5 @@
1
1
  module ResqueUnit
2
-
2
+
3
3
  # ResqueUnit::Scheduler is a group of functions mocking the behavior
4
4
  # of resque-scheduler. It is included into Resque when
5
5
  # 'resque_unit_scheduler' is required.
@@ -11,28 +11,30 @@ module ResqueUnit
11
11
  def enqueue_at(timestamp, klass, *args)
12
12
  enqueue_with_timestamp(timestamp, klass, *args)
13
13
  end
14
-
14
+
15
15
  # Identical to enqueue_at but takes number_of_seconds_from_now
16
16
  # instead of a timestamp.
17
17
  def enqueue_in(number_of_seconds_from_now, klass, *args)
18
18
  enqueue_at(Time.now + number_of_seconds_from_now, klass, *args)
19
19
  end
20
-
20
+
21
21
  def enqueue_with_timestamp(timestamp, klass, *args)
22
- enqueue_unit(queue_for(klass), {:klass => klass, :args => decode(encode(args)), :timestamp => timestamp})
22
+ enqueue_unit(queue_for(klass), {"class" => klass.name, "args" => args, "timestamp" => timestamp})
23
23
  end
24
24
 
25
25
  def remove_delayed(klass, *args)
26
- queue = Resque.queue(queue_for(klass))
27
- if args # retrieve the elements that match klass and args in the queue
28
- args = Resque.normalized_args(args)
29
- queue.delete_if { |e| e[:klass] == klass && e[:args] == args }
30
- else # if no args were passed, retrieve all queued jobs that match klass
31
- queue.delete_if {|e| e[:klass] == klass}
32
- end
26
+ # points to real queue
27
+ encoded_job_payloads = Resque.queue(queue_for(klass))
28
+ args ||= []
29
+ encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && e["args"] == args }
30
+ end
31
+
32
+ def remove_delayed_job_from_timestamp(timestamp, klass, *args)
33
+ encoded_job_payloads = Resque.queue(queue_for(klass))
34
+ args ||= []
35
+ encoded_job_payloads.delete_if { |e| e = Resque.decode(e); e["class"] == klass.to_s && Time.parse(e["timestamp"]).to_i == Time.parse(timestamp.to_s).to_i && e["args"] == args }
33
36
  end
34
37
  end
35
38
 
36
39
  Resque.send(:extend, Scheduler)
37
40
  end
38
-
@@ -1,5 +1,7 @@
1
1
  # These are a group of assertions you can use in your unit tests to
2
2
  # verify that your code is using resque-scheduler correctly.
3
+ require 'time'
4
+
3
5
  module ResqueUnit::SchedulerAssertions
4
6
 
5
7
  # Asserts that +klass+ has been queued into its appropriate queue at
@@ -12,9 +14,8 @@ module ResqueUnit::SchedulerAssertions
12
14
  # arguments.
13
15
  def assert_queued_at(expected_timestamp, klass, args = nil, message = nil)
14
16
  queue = Resque.queue_for(klass)
15
- assert_block (message || "#{klass} should have been queued in #{queue} before #{expected_timestamp}: #{Resque.queue(queue).inspect}.") do
16
- in_timestamped_queue?(queue, expected_timestamp, klass, args)
17
- end
17
+ assert in_timestamped_queue?(queue, expected_timestamp, klass, args),
18
+ (message || "#{klass} should have been queued in #{queue} before #{expected_timestamp}: #{Resque.queue(queue).inspect}.")
18
19
  end
19
20
 
20
21
  # Similar to +assert_queued_at+, except it takes an expected time
@@ -26,9 +27,8 @@ module ResqueUnit::SchedulerAssertions
26
27
  # opposite of +assert_queued_at+
27
28
  def assert_not_queued_at(expected_timestamp, klass, args = nil, message = nil)
28
29
  queue = Resque.queue_for(klass)
29
- assert_block (message || "#{klass} should not have been queued in #{queue} before #{expected_timestamp}.") do
30
- !in_timestamped_queue?(queue, expected_timestamp, klass, args)
31
- end
30
+ assert !in_timestamped_queue?(queue, expected_timestamp, klass, args),
31
+ (message || "#{klass} should not have been queued in #{queue} before #{expected_timestamp}.")
32
32
  end
33
33
 
34
34
  # opposite of +assert_queued_in+
@@ -41,7 +41,7 @@ module ResqueUnit::SchedulerAssertions
41
41
  def in_timestamped_queue?(queue_name, expected_timestamp, klass, args = nil)
42
42
  # check if we have any matching jobs with a timestamp less than
43
43
  # expected_timestamp
44
- !matching_jobs(Resque.queue(queue_name), klass, args).select {|e| e[:timestamp] && e[:timestamp] <= expected_timestamp}.empty?
44
+ !matching_jobs(Resque.all(queue_name), klass, args).select {|e| e["timestamp"] && Time.parse(e["timestamp"]) <= expected_timestamp}.empty?
45
45
  end
46
46
 
47
47
  end
data/lib/resque_unit.rb CHANGED
@@ -7,12 +7,20 @@ rescue LoadError
7
7
  require 'json'
8
8
  end
9
9
 
10
- require 'test/unit'
11
10
  require 'resque_unit/helpers'
12
11
  require 'resque_unit/resque'
13
12
  require 'resque_unit/errors'
14
13
  require 'resque_unit/assertions'
15
- require 'resque_unit/plugin'
14
+ require 'resque_unit/plugin'
16
15
 
17
- Test::Unit::TestCase.send(:include, ResqueUnit::Assertions)
16
+ if defined?(Test::Unit)
17
+ Test::Unit::TestCase.send(:include, ResqueUnit::Assertions)
18
+ end
19
+
20
+ if defined?(MiniTest::Unit::TestCase)
21
+ MiniTest::Unit::TestCase.send(:include, ResqueUnit::Assertions)
22
+ end
18
23
 
24
+ if defined?(Minitest::Test)
25
+ Minitest::Test.send(:include, ResqueUnit::Assertions)
26
+ end
@@ -1,4 +1,14 @@
1
1
  require 'resque_unit/scheduler'
2
2
  require 'resque_unit/scheduler_assertions'
3
3
 
4
- Test::Unit::TestCase.send(:include, ResqueUnit::SchedulerAssertions)
4
+ if defined?(Test::Unit)
5
+ Test::Unit::TestCase.send(:include, ResqueUnit::SchedulerAssertions)
6
+ end
7
+
8
+ if defined?(MiniTest::Unit::TestCase)
9
+ MiniTest::Unit::TestCase.send(:include, ResqueUnit::SchedulerAssertions)
10
+ end
11
+
12
+ if defined?(Minitest::Test)
13
+ Minitest::Test.send(:include, ResqueUnit::SchedulerAssertions)
14
+ end
@@ -0,0 +1,61 @@
1
+ require 'test_helper'
2
+
3
+ class ResqueTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ Resque.reset!
7
+ end
8
+
9
+ context "with one queued job" do
10
+ setup do
11
+ Resque.enqueue(MediumPriorityJob, "some args")
12
+ @job_payload = {"args"=>["some args"], "class"=>"MediumPriorityJob"}
13
+ end
14
+
15
+ should "return job payload when peek method called with count equal 1" do
16
+ assert_equal @job_payload, Resque.peek(MediumPriorityJob.queue, 0, 1)
17
+ end
18
+
19
+ should "return array of jobs' payloads when peek method called with count different than 1" do
20
+ assert_equal [@job_payload], Resque.peek(MediumPriorityJob.queue, 0, 5)
21
+ end
22
+ end
23
+
24
+ context "with few queued jobs" do
25
+ setup do
26
+ Resque.enqueue(MediumPriorityJob, "1")
27
+ Resque.enqueue(MediumPriorityJob, "2")
28
+ Resque.enqueue(MediumPriorityJob, "3")
29
+ end
30
+
31
+ should "return jobs' payloads 2 and 3 when peek method called with start equal 1 and count equal 2" do
32
+ assert_equal [["2"], ["3"]], Resque.peek(MediumPriorityJob.queue, 1, 2).map{|h| h["args"]}
33
+ end
34
+
35
+ should "return empty array when peek method called with start higher than queue size" do
36
+ assert_equal [], Resque.peek(MediumPriorityJob.queue, 4, 2)
37
+ end
38
+
39
+ should "return empty array when peek method called with count equal 0" do
40
+ assert_equal [], Resque.peek(MediumPriorityJob.queue, 0, 0)
41
+ end
42
+
43
+ should "return all jobs' payloads when all method called" do
44
+ assert Resque.all(MediumPriorityJob.queue).length == 3, "should return all 3 elements"
45
+ end
46
+ end
47
+
48
+ context "without queued jobs" do
49
+ should "return nil when peek method called with count equal 1" do
50
+ assert_equal nil, Resque.peek(MediumPriorityJob.queue, 0, 1)
51
+ end
52
+
53
+ should "return empty array when peek method called with count not equal 1" do
54
+ assert_equal [], Resque.peek(MediumPriorityJob.queue, 0, 999)
55
+ end
56
+
57
+ should "return empty array when all method called" do
58
+ assert_equal [], Resque.all(MediumPriorityJob.queue)
59
+ end
60
+ end
61
+ end
@@ -18,12 +18,12 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  should "fail the assert_queued_in(300, job) assertion" do
21
- assert_raise Test::Unit::AssertionFailedError do
21
+ assert_raise Test::Unit::AssertionFailedError do
22
22
  assert_queued_in(300, MediumPriorityJob)
23
23
  end
24
24
  end
25
25
 
26
- should "pass the assert_not_queued_in(300, job) assertion" do
26
+ should "pass the assert_not_queued_in(300, job) assertion" do
27
27
  assert_not_queued_in(300, MediumPriorityJob)
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
31
31
  setup do
32
32
  Resque.remove_delayed(MediumPriorityJob)
33
33
  end
34
- should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
34
+ should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
35
35
  assert_not_queued_at(300, MediumPriorityJob)
36
36
  end
37
37
 
@@ -42,7 +42,7 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
42
42
  end
43
43
  end
44
44
  end
45
-
45
+
46
46
  context "A task that schedules a resque job in 5 minutes with arguments" do
47
47
  setup { Resque.enqueue_in(600, JobWithArguments, 1, "test") }
48
48
  should "pass the assert_queued_in(600, JobWithArguments) assertion" do
@@ -53,8 +53,8 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
53
53
  assert_queued_in(600, JobWithArguments, [1, 'test'])
54
54
  end
55
55
 
56
- should "fail the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
57
- assert_raise Test::Unit::AssertionFailedError do
56
+ should "fail the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
57
+ assert_raise Test::Unit::AssertionFailedError do
58
58
  assert_queued_in(600, JobWithArguments, [2, 'test'])
59
59
  end
60
60
  end
@@ -63,7 +63,7 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
63
63
  setup do
64
64
  Resque.remove_delayed(JobWithArguments, 1, 'test')
65
65
  end
66
- should "pass the assert_not_queued_at(@time, JobWithArguments, 1, 'test') assertion" do
66
+ should "pass the assert_not_queued_at(@time, JobWithArguments, 1, 'test') assertion" do
67
67
  assert_not_queued_at(600, JobWithArguments, 1, 'test')
68
68
  end
69
69
 
@@ -86,26 +86,26 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
86
86
  assert_queued_in(600, JobWithArguments, [1, 'test'])
87
87
  end
88
88
 
89
- should "still fail the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
90
- assert_raise Test::Unit::AssertionFailedError do
89
+ should "still fail the assert_queued_in(600, JobWithArguments, [2, 'test']) assertion" do
90
+ assert_raise Test::Unit::AssertionFailedError do
91
91
  assert_queued_in(600, JobWithArguments, [2, 'test'])
92
92
  end
93
93
  end
94
94
  end
95
95
  end
96
-
96
+
97
97
  context "A task that schedules a resque job on Sept. 6, 2016 at 6am" do
98
98
  setup do
99
99
  @time = Time.mktime(2016, 9, 6, 6)
100
100
  Resque.enqueue_at(@time, MediumPriorityJob)
101
101
  end
102
102
 
103
- should "pass the assert_queued_at(@time, MediumPriorityJob) assertion" do
103
+ should "pass the assert_queued_at(@time, MediumPriorityJob) assertion" do
104
104
  assert_queued_at(@time, MediumPriorityJob)
105
105
  end
106
106
 
107
- should "fail the assert_queued_at(@time - 100, MediumPriorityJob) assertion" do
108
- assert_raise Test::Unit::AssertionFailedError do
107
+ should "fail the assert_queued_at(@time - 100, MediumPriorityJob) assertion" do
108
+ assert_raise Test::Unit::AssertionFailedError do
109
109
  assert_queued_at(@time - 100, MediumPriorityJob)
110
110
  end
111
111
  end
@@ -118,7 +118,39 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
118
118
  setup do
119
119
  Resque.remove_delayed(MediumPriorityJob)
120
120
  end
121
- should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
121
+ should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
122
+ assert_not_queued_at(@time, MediumPriorityJob)
123
+ end
124
+
125
+ should "fail the assert_queued_at(@time, MediumPriorityJob) assertion" do
126
+ assert_raise Test::Unit::AssertionFailedError do
127
+ assert_queued_at(@time, MediumPriorityJob)
128
+ end
129
+ end
130
+ end
131
+
132
+ context "and then the job is removed with #remove_delayed_job_from_timestamp" do
133
+ setup do
134
+ Resque.remove_delayed_job_from_timestamp(@time, MediumPriorityJob)
135
+ end
136
+
137
+ should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
138
+ assert_not_queued_at(@time, MediumPriorityJob)
139
+ end
140
+
141
+ should "fail the assert_queued_at(@time, MediumPriorityJob) assertion" do
142
+ assert_raise Test::Unit::AssertionFailedError do
143
+ assert_queued_at(@time, MediumPriorityJob)
144
+ end
145
+ end
146
+ end
147
+
148
+ context "and then the job is removed with #remove_delayed_job_from_timestamp with timestamp specified in another timezone" do
149
+ setup do
150
+ Resque.remove_delayed_job_from_timestamp(@time.utc, MediumPriorityJob)
151
+ end
152
+
153
+ should "pass the assert_not_queued_at(@time, MediumPriorityJob) assertion" do
122
154
  assert_not_queued_at(@time, MediumPriorityJob)
123
155
  end
124
156
 
@@ -129,4 +161,73 @@ class ResqueUnitSchedulerTest < Test::Unit::TestCase
129
161
  end
130
162
  end
131
163
  end
164
+
165
+ context "A task that schedules a resque job with arguments on on Sept. 6, 2016 at 6am" do
166
+ setup do
167
+ @time = Time.mktime(2016, 9, 6, 6)
168
+ Resque.enqueue_at(@time, JobWithArguments, 1, "test")
169
+ end
170
+
171
+ should "pass the assert_queued_at(@time, JobWithArguments, *args) assertion" do
172
+ assert_queued_at(@time, JobWithArguments, [1, "test"])
173
+ end
174
+
175
+ should "fail the assert_queued_at(@time - 100, JobWithArguments, *args) assertion" do
176
+ assert_raise Test::Unit::AssertionFailedError do
177
+ assert_queued_at(@time - 100, JobWithArguments, [1, "test"])
178
+ end
179
+ end
180
+
181
+ should "pass the assert_not_queued_at(@time - 100, JobWithArguments, *args) assertion" do
182
+ assert_not_queued_at(@time - 100, JobWithArguments, [1, "test"])
183
+ end
184
+
185
+ context "and then the job is removed with #remove_delayed" do
186
+ setup do
187
+ Resque.remove_delayed(JobWithArguments, 1, "test")
188
+ end
189
+
190
+ should "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
191
+ assert_not_queued_at(@time, JobWithArguments, [1, "test"])
192
+ end
193
+
194
+ should "fail the assert_queued_at(@time, JobWithArguments, *args) assertion" do
195
+ assert_raise Test::Unit::AssertionFailedError do
196
+ assert_queued_at(@time, JobWithArguments, [1, "test"])
197
+ end
198
+ end
199
+ end
200
+
201
+ context "and then the job is removed with #remove_delayed_job_from_timestamp" do
202
+ setup do
203
+ Resque.remove_delayed_job_from_timestamp(@time, JobWithArguments, 1, "test")
204
+ end
205
+
206
+ should "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
207
+ assert_not_queued_at(@time, JobWithArguments, [1, "test"])
208
+ end
209
+
210
+ should "fail the assert_queued_at(@time, MediumPriorityJob, *args) assertion" do
211
+ assert_raise Test::Unit::AssertionFailedError do
212
+ assert_queued_at(@time, JobWithArguments, [1, "test"])
213
+ end
214
+ end
215
+ end
216
+
217
+ context "and then the job is removed with #remove_delayed_job_from_timestamp with timestamp in another timezone" do
218
+ setup do
219
+ Resque.remove_delayed_job_from_timestamp(@time.utc, JobWithArguments, 1, "test")
220
+ end
221
+
222
+ should "pass the assert_not_queued_at(@time, JobWithArguments, *args) assertion" do
223
+ assert_not_queued_at(@time, JobWithArguments, [1, "test"])
224
+ end
225
+
226
+ should "fail the assert_queued_at(@time, MediumPriorityJob, *args) assertion" do
227
+ assert_raise Test::Unit::AssertionFailedError do
228
+ assert_queued_at(@time, JobWithArguments, [1, "test"])
229
+ end
230
+ end
231
+ end
232
+ end
132
233
  end
@@ -17,8 +17,42 @@ class ResqueUnitTest < Test::Unit::TestCase
17
17
  end
18
18
  end
19
19
 
20
+ context "A task that explicitly is queued to a different queue" do
21
+ setup { Resque.enqueue_to(:a_non_class_determined_queue, MediumPriorityJob) }
22
+ should "not queue to the class-determined queue" do
23
+ assert_equal 0, Resque.queue(MediumPriorityJob.queue).length
24
+ end
25
+ should "queue to the explicly-stated queue" do
26
+ assert_equal 1, Resque.queue(:a_non_class_determined_queue).length
27
+ end
28
+ end
29
+
30
+ context "A task that spawns multiple jobs on a single queue" do
31
+ setup do
32
+ 3.times {Resque.enqueue(HighPriorityJob)}
33
+ end
34
+
35
+ should "allow partial runs with explicit limit" do
36
+ assert_equal 3, Resque.queue(:high).length, 'failed setup'
37
+ Resque.run_for!( :high, 1 )
38
+ assert_equal 2, Resque.queue(:high).length, 'failed to run just single job'
39
+ end
40
+
41
+ should "allow full run with too-large explicit limit" do
42
+ assert_equal 3, Resque.queue(:high).length, 'failed setup'
43
+ Resque.run_for!( :high, 50 )
44
+ assert_equal 0, Resque.queue(:high).length, 'failed to run all jobs'
45
+ end
46
+
47
+ should "allow full run with implicit limit" do
48
+ assert_equal 3, Resque.queue(:high).length, 'failed setup'
49
+ Resque.run_for!( :high )
50
+ assert_equal 0, Resque.queue(:high).length, 'failed to run all jobs'
51
+ end
52
+ end
53
+
20
54
  context "A task that schedules a resque job" do
21
- setup do
55
+ setup do
22
56
  @returned = Resque.enqueue(LowPriorityJob)
23
57
  end
24
58
 
@@ -26,12 +60,12 @@ class ResqueUnitTest < Test::Unit::TestCase
26
60
  assert @returned
27
61
  end
28
62
 
29
- should "pass the assert_queued(job) assertion" do
63
+ should "pass the assert_queued(job) assertion" do
30
64
  assert_queued(LowPriorityJob)
31
65
  end
32
66
 
33
- should "fail the assert_not_queued(job) assertion" do
34
- assert_raise Test::Unit::AssertionFailedError do
67
+ should "fail the assert_not_queued(job) assertion" do
68
+ assert_raise Test::Unit::AssertionFailedError do
35
69
  assert_not_queued(LowPriorityJob)
36
70
  end
37
71
  end
@@ -40,17 +74,17 @@ class ResqueUnitTest < Test::Unit::TestCase
40
74
  assert_equal 1, Resque.size(:low)
41
75
  end
42
76
 
43
- context ", when Resque.run! is called," do
44
- setup do
77
+ context ", when Resque.run! is called," do
78
+ setup do
45
79
  assert !LowPriorityJob.run?, "The job should not have been run yet"
46
80
  Resque.run!
47
81
  end
48
-
49
- teardown do
82
+
83
+ teardown do
50
84
  LowPriorityJob.run = false
51
85
  end
52
86
 
53
- should "run the job" do
87
+ should "run the job" do
54
88
  assert LowPriorityJob.run?, "The job should have run"
55
89
  end
56
90
 
@@ -63,51 +97,96 @@ class ResqueUnitTest < Test::Unit::TestCase
63
97
  end
64
98
 
65
99
  context "A task that schedules a resque job with hooks" do
66
- setup do
100
+ setup do
67
101
  Resque.enable_hooks!
68
- JobWithHooks.clear_markers
69
- Resque.enqueue(JobWithHooks)
70
102
  end
71
103
 
72
104
  teardown do
73
105
  Resque.disable_hooks!
74
106
  end
75
107
 
76
- should "have run the after_enqueue hook" do
77
- assert_queued(JobWithHooks)
78
- assert(JobWithHooks.markers[:after_enqueue], 'no after_queue marker set')
79
- end
108
+ context "before, around, after, failure, after_enqueue" do
109
+ setup do
110
+ JobWithHooks.clear_markers
111
+ Resque.enqueue(JobWithHooks)
112
+ end
80
113
 
81
- should "run the before and after hooks during a run" do
82
- Resque.run!
83
- assert(JobWithHooks.markers[:before], 'no before marker set')
84
- assert(JobWithHooks.markers[:around], 'no around marker set')
85
- assert(JobWithHooks.markers[:after], 'no after marker set')
86
- assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
87
- end
114
+ should "have run the after_enqueue hook" do
115
+ assert_queued(JobWithHooks)
116
+ assert(JobWithHooks.markers[:after_enqueue], 'no after_queue marker set')
117
+ end
118
+
119
+ should "have run the before_enqueue hook" do
120
+ assert(JobWithHooks.markers[:before_enqueue], 'no before_queue marker set')
121
+ assert_queued(JobWithHooks)
122
+ end
123
+
124
+ should "run the before and after hooks during a run" do
125
+ Resque.run!
126
+ assert(JobWithHooks.markers[:before], 'no before marker set')
127
+ assert(JobWithHooks.markers[:around], 'no around marker set')
128
+ assert(JobWithHooks.markers[:after], 'no after marker set')
129
+ assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
130
+ end
131
+
132
+ should "run the before and failed hooks during a run" do
133
+ JobWithHooks.make_it_fail do
134
+ assert_raise(RuntimeError) do
135
+ Resque.run!
136
+ assert(JobWithHooks.markers[:before], 'no before marker set')
137
+ assert(JobWithHooks.markers[:around], 'no around marker set')
138
+ assert(!JobWithHooks.markers[:after], 'after marker set, and it should not')
139
+ assert(JobWithHooks.markers[:failed], 'no failed marker set')
140
+ end
141
+ end
142
+ end
88
143
 
89
- should "run the before and failed hooks during a run" do
90
- JobWithHooks.make_it_fail do
91
- assert_raise(RuntimeError) do
144
+ should "not call perform if the around hook raised Resque::Job::DontPerform" do
145
+ JobWithHooks.make_it_dont_perform do
92
146
  Resque.run!
93
147
  assert(JobWithHooks.markers[:before], 'no before marker set')
94
148
  assert(JobWithHooks.markers[:around], 'no around marker set')
95
149
  assert(!JobWithHooks.markers[:after], 'after marker set, and it should not')
96
- assert(JobWithHooks.markers[:failed], 'no failed marker set')
150
+ assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
97
151
  end
98
152
  end
99
153
  end
100
154
 
101
- should "not call perform if the around hook raised Resque::Job::DontPerform" do
102
- JobWithHooks.make_it_dont_perform do
155
+ context "but without before" do
156
+ setup do
157
+ JobWithHooksWithoutBefore.clear_markers
158
+ Resque.enqueue(JobWithHooksWithoutBefore)
159
+ end
160
+
161
+ should "not run before hooks during a run" do
103
162
  Resque.run!
104
- assert(JobWithHooks.markers[:before], 'no before marker set')
105
- assert(JobWithHooks.markers[:around], 'no around marker set')
106
- assert(!JobWithHooks.markers[:after], 'after marker set, and it should not')
107
- assert(!JobWithHooks.markers[:failed], 'failed marker set, and it should not')
163
+ assert(!JobWithHooksWithoutBefore.markers[:before], 'before marker set, and it should not')
164
+ end
165
+ end
166
+
167
+ context "when before_enqueue returns false" do
168
+ setup do
169
+ JobWithHooksBeforeBlocks.clear_markers
170
+ end
171
+
172
+ should "not queue" do
173
+ Resque.enqueue JobWithHooksBeforeBlocks
174
+ assert_not_queued JobWithHooksBeforeBlocks
108
175
  end
176
+
109
177
  end
110
178
 
179
+ context "but without around" do
180
+ setup do
181
+ JobWithHooksWithoutAround.clear_markers
182
+ Resque.enqueue(JobWithHooksWithoutAround)
183
+ end
184
+
185
+ should "not run around hooks during a run" do
186
+ Resque.run!
187
+ assert(!JobWithHooksWithoutAround.markers[:around], 'around marker set, and it should not')
188
+ end
189
+ end
111
190
  end
112
191
 
113
192
  context "Block assertions" do
@@ -117,14 +196,14 @@ class ResqueUnitTest < Test::Unit::TestCase
117
196
  end
118
197
  end
119
198
 
120
- should "pass the assert_queued(job) assertion when queued and not in block" do
199
+ should "pass the assert_queued(job) assertion when queued in block and outside" do
121
200
  Resque.enqueue(HighPriorityJob)
122
201
  assert_queues(HighPriorityJob) do
123
202
  Resque.enqueue(HighPriorityJob)
124
203
  end
125
204
  end
126
205
 
127
- should "fail the assert_queued(job) assertion when not queued in block" do
206
+ should "fail the assert_queued(job) assertion when not queued in block but outside" do
128
207
  Resque.enqueue(LowPriorityJob)
129
208
  assert_raise Test::Unit::AssertionFailedError do
130
209
  assert_queues(LowPriorityJob) do
@@ -174,12 +253,12 @@ class ResqueUnitTest < Test::Unit::TestCase
174
253
  end
175
254
 
176
255
  context "An empty queue" do
177
- should "pass the assert_not_queued(job) assertion" do
256
+ should "pass the assert_not_queued(job) assertion" do
178
257
  assert_not_queued(LowPriorityJob)
179
258
  end
180
259
 
181
260
  should "fail the assert_queued(job) assertion" do
182
- assert_raise Test::Unit::AssertionFailedError do
261
+ assert_raise Test::Unit::AssertionFailedError do
183
262
  assert_queued(LowPriorityJob)
184
263
  end
185
264
  end
@@ -188,16 +267,16 @@ class ResqueUnitTest < Test::Unit::TestCase
188
267
  assert_equal 0, Resque.size(:low)
189
268
  end
190
269
  end
191
-
192
- context "A task that schedules a resque job with arguments" do
193
- setup do
270
+
271
+ context "A task that schedules a resque job with arguments" do
272
+ setup do
194
273
  Resque.enqueue(JobWithArguments, 1, :test, {:symbol => :symbol})
195
274
  end
196
-
275
+
197
276
  should "pass the assert_queued(job, *args) assertion if the args match and sees enqueued symbols as strings" do
198
277
  assert_queued(JobWithArguments, [1, "test", {"symbol"=>"symbol"}])
199
278
  end
200
-
279
+
201
280
  should "pass the assert_queued(job, *args) assertion if the args match using symbols" do
202
281
  assert_queued(JobWithArguments, [1, :test, {:symbol => :symbol}])
203
282
  end
@@ -206,8 +285,8 @@ class ResqueUnitTest < Test::Unit::TestCase
206
285
  assert_queued(JobWithArguments)
207
286
  end
208
287
 
209
- should "fail the assert_queued(job) assertion if the args don't match" do
210
- assert_raise Test::Unit::AssertionFailedError do
288
+ should "fail the assert_queued(job) assertion if the args don't match" do
289
+ assert_raise Test::Unit::AssertionFailedError do
211
290
  assert_queued(JobWithArguments, [2, "test"])
212
291
  end
213
292
  end
@@ -217,23 +296,23 @@ class ResqueUnitTest < Test::Unit::TestCase
217
296
  end
218
297
 
219
298
  should "fail the assert_not_queued(job) assertion if the args match" do
220
- assert_raise Test::Unit::AssertionFailedError do
299
+ assert_raise Test::Unit::AssertionFailedError do
221
300
  assert_not_queued(JobWithArguments, [1, "test", {"symbol"=>"symbol"}])
222
301
  end
223
302
  end
224
303
  end
225
304
 
226
305
  context "A job that schedules a new resque job" do
227
- setup do
306
+ setup do
228
307
  Resque.enqueue(JobThatCreatesANewJob)
229
308
  end
230
309
 
231
- should "pass the assert_queued(job) assertion" do
310
+ should "pass the assert_queued(job) assertion" do
232
311
  assert_queued(JobThatCreatesANewJob)
233
312
  end
234
313
 
235
- should "fail the assert_not_queued(job) assertion" do
236
- assert_raise Test::Unit::AssertionFailedError do
314
+ should "fail the assert_not_queued(job) assertion" do
315
+ assert_raise Test::Unit::AssertionFailedError do
237
316
  assert_not_queued(JobThatCreatesANewJob)
238
317
  end
239
318
  end
@@ -242,8 +321,8 @@ class ResqueUnitTest < Test::Unit::TestCase
242
321
  assert_not_queued(LowPriorityJob)
243
322
  end
244
323
 
245
- context ", when Resque.run! is called," do
246
- setup do
324
+ context ", when Resque.run! is called," do
325
+ setup do
247
326
  Resque.run!
248
327
  end
249
328
 
@@ -262,7 +341,7 @@ class ResqueUnitTest < Test::Unit::TestCase
262
341
  Resque.full_run!
263
342
  end
264
343
 
265
- teardown do
344
+ teardown do
266
345
  LowPriorityJob.run = false
267
346
  end
268
347
 
@@ -291,10 +370,10 @@ class ResqueUnitTest < Test::Unit::TestCase
291
370
  assert_queued(HighPriorityJob)
292
371
  end
293
372
 
294
- context ", when Resque.run_for! is called," do
373
+ context ", when Resque.run_for! is called," do
295
374
  should "run only tasks in the high priority queue" do
296
375
  Resque.run_for!(Resque.queue_for(HighPriorityJob))
297
-
376
+
298
377
  assert_queued(LowPriorityJob)
299
378
  assert_not_queued(HighPriorityJob)
300
379
  end
@@ -310,7 +389,7 @@ class ResqueUnitTest < Test::Unit::TestCase
310
389
  assert_equal "LowPriorityJob should have been queued in low: [].", error.message
311
390
  end
312
391
  end
313
-
392
+
314
393
  should "include job arguments if provided" do
315
394
  begin
316
395
  assert_not_queued(JobWithArguments, [1, "test"])
@@ -329,7 +408,7 @@ class ResqueUnitTest < Test::Unit::TestCase
329
408
  assert_equal "LowPriorityJob should not have been queued in low.", error.message
330
409
  end
331
410
  end
332
-
411
+
333
412
  should "include job arguments if provided" do
334
413
  begin
335
414
  Resque.enqueue(JobWithArguments, 1, "test")
data/test/sample_jobs.rb CHANGED
@@ -49,10 +49,30 @@ class JobThatDoesNotSpecifyAQueue
49
49
  end
50
50
  end
51
51
 
52
+ module HooksMethods
53
+ def after_enqueue_mark(*args)
54
+ markers[:after_enqueue] = true
55
+ end
56
+
57
+ def before_enqueue_mark(*args)
58
+ markers[:before_enqueue] = true
59
+ end
60
+
61
+ def after_perform_mark(*args)
62
+ markers[:after] = true
63
+ end
64
+
65
+ def failure_perform_mark(*args)
66
+ markers[:failure] = true
67
+ end
68
+ end
69
+
52
70
  class JobWithHooks
71
+ extend HooksMethods
72
+
53
73
  @queue = :with_hooks
54
74
  @markers = {}
55
-
75
+
56
76
  def self.perform
57
77
  raise 'FAIL!' if @will_fail
58
78
  end
@@ -65,10 +85,6 @@ class JobWithHooks
65
85
  @markers = {}
66
86
  end
67
87
 
68
- def self.after_enqueue_mark(*args)
69
- markers[:after_enqueue] = true
70
- end
71
-
72
88
  def self.before_perform_mark(*args)
73
89
  markers[:before] = true
74
90
  end
@@ -82,14 +98,6 @@ class JobWithHooks
82
98
  end
83
99
  end
84
100
 
85
- def self.after_perform_mark(*args)
86
- markers[:after] = true
87
- end
88
-
89
- def self.failure_perform_mark(*args)
90
- markers[:failure] = true
91
- end
92
-
93
101
  def self.make_it_fail(&block)
94
102
  @will_fail = true
95
103
  yield
@@ -102,5 +110,58 @@ class JobWithHooks
102
110
  ensure
103
111
  @dont_perform = false
104
112
  end
113
+ end
114
+
115
+ class JobWithHooksBeforeBlocks < JobWithHooks
116
+ @queue = :with_hooks
117
+ def self.before_enqueue_block_enqueueing
118
+ return false
119
+ end
120
+ end
121
+
122
+ class JobWithHooksWithoutBefore
123
+ extend HooksMethods
124
+
125
+ @queue = :with_hooks
126
+ @markers = {}
127
+
128
+ def self.markers
129
+ @markers
130
+ end
131
+
132
+ def self.clear_markers
133
+ @markers = {}
134
+ end
135
+
136
+ def self.perform; end
137
+
138
+ def self.around_perform_mark(*args)
139
+ markers[:around] = true
140
+ if @dont_perform
141
+ raise Resque::Job::DontPerform
142
+ else
143
+ yield
144
+ end
145
+ end
146
+ end
147
+
148
+ class JobWithHooksWithoutAround
149
+ extend HooksMethods
150
+
151
+ @queue = :with_hooks
152
+ @markers = {}
153
+
154
+ def self.markers
155
+ @markers
156
+ end
105
157
 
106
- end
158
+ def self.clear_markers
159
+ @markers = {}
160
+ end
161
+
162
+ def self.perform; end
163
+
164
+ def self.before_perform_mark(*args)
165
+ markers[:before] = true
166
+ end
167
+ end
metadata CHANGED
@@ -1,72 +1,66 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: resque_unit
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 3
8
- - 6
9
- version: 0.3.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.8
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Justin Weiss
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2011-04-11 00:00:00 -07:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: json
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ~>
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 4
30
- - 6
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
31
19
  version: 1.4.6
32
20
  type: :runtime
33
21
  prerelease: false
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.6
27
+ - !ruby/object:Gem::Dependency
36
28
  name: bundler
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
40
31
  - - ">="
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 0
44
- version: "0"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
45
34
  type: :development
46
35
  prerelease: false
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
49
42
  name: shoulda
50
- requirement: &id003 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
53
45
  - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- version: "0"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
58
48
  type: :development
59
49
  prerelease: false
60
- version_requirements: *id003
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
61
55
  description:
62
56
  email: justin@uberweiss.org
63
57
  executables: []
64
-
65
58
  extensions: []
66
-
67
- extra_rdoc_files:
59
+ extra_rdoc_files:
60
+ - README.md
61
+ files:
68
62
  - README.md
69
- files:
63
+ - lib/resque_unit.rb
70
64
  - lib/resque_unit/assertions.rb
71
65
  - lib/resque_unit/errors.rb
72
66
  - lib/resque_unit/helpers.rb
@@ -74,47 +68,37 @@ files:
74
68
  - lib/resque_unit/resque.rb
75
69
  - lib/resque_unit/scheduler.rb
76
70
  - lib/resque_unit/scheduler_assertions.rb
77
- - lib/resque_unit.rb
78
71
  - lib/resque_unit_scheduler.rb
72
+ - test/resque_test.rb
79
73
  - test/resque_unit_scheduler_test.rb
80
74
  - test/resque_unit_test.rb
81
75
  - test/sample_jobs.rb
82
76
  - test/test_helper.rb
83
- - README.md
84
- has_rdoc: true
85
77
  homepage: http://github.com/justinweiss/resque_unit
86
- licenses: []
87
-
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
88
81
  post_install_message:
89
82
  rdoc_options: []
90
-
91
- require_paths:
83
+ require_paths:
92
84
  - lib
93
- required_ruby_version: !ruby/object:Gem::Requirement
94
- none: false
95
- requirements:
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
96
87
  - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: -549847167591292216
99
- segments:
100
- - 0
101
- version: "0"
102
- required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
105
92
  - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: -549847167591292216
108
- segments:
109
- - 0
110
- version: "0"
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
111
95
  requirements: []
112
-
113
96
  rubyforge_project:
114
- rubygems_version: 1.3.7
97
+ rubygems_version: 2.2.2
115
98
  signing_key:
116
- specification_version: 3
99
+ specification_version: 4
117
100
  summary: Test::Unit support for resque job queueing
118
- test_files:
101
+ test_files:
102
+ - test/resque_test.rb
119
103
  - test/resque_unit_scheduler_test.rb
120
104
  - test/resque_unit_test.rb