Skip to content

Commit 8f49a43

Browse files
committed
convert the test suite to minitest
1 parent 8e2c65c commit 8f49a43

11 files changed

+165
-158
lines changed

lib/resque/server/test_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
module Resque
55
module TestHelper
6-
class Test::Unit::TestCase
6+
class MiniTest::Unit::TestCase
77
include Rack::Test::Methods
88
def app
99
Resque::Server.new
1010
end
1111

1212
def self.should_respond_with_success
13-
test "should respond with success" do
13+
it "should respond with success" do
1414
assert last_response.ok?, last_response.errors
1515
end
1616
end

test/airbrake_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
require 'test_helper'
32

43
begin
@@ -9,8 +8,8 @@
98

109
if defined? Airbrake
1110
require 'resque/failure/airbrake'
12-
context "Airbrake" do
13-
test "should be notified of an error" do
11+
describe "Airbrake" do
12+
it "should be notified of an error" do
1413
exception = StandardError.new("BOOM")
1514
worker = Resque::Worker.new(:test)
1615
queue = "test"

test/hoptoad_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
if defined? HoptoadNotifier
1010
require 'resque/failure/hoptoad'
11-
context "Hoptoad" do
12-
test "should be notified of an error" do
11+
describe "Hoptoad" do
12+
it "should be notified of an error" do
1313
exception = StandardError.new("BOOM")
1414
worker = Resque::Worker.new(:test)
1515
queue = "test"

test/job_hooks_test.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'test_helper'
22

3-
context "Resque::Job before_perform" do
3+
describe "Resque::Job before_perform" do
44
include PerformJob
55

66
class ::BeforePerformJob
@@ -13,7 +13,7 @@ def self.perform(history)
1313
end
1414
end
1515

16-
test "it runs before_perform before perform" do
16+
it "it runs before_perform before perform" do
1717
result = perform_job(BeforePerformJob, history=[])
1818
assert_equal true, result, "perform returned true"
1919
assert_equal history, [:before_perform, :perform]
@@ -29,7 +29,7 @@ def self.perform(history)
2929
end
3030
end
3131

32-
test "raises an error and does not perform if before_perform fails" do
32+
it "raises an error and does not perform if before_perform fails" do
3333
history = []
3434
assert_raises StandardError do
3535
perform_job(BeforePerformJobFails, history)
@@ -47,14 +47,14 @@ def self.perform(history)
4747
end
4848
end
4949

50-
test "does not perform if before_perform raises Resque::Job::DontPerform" do
50+
it "does not perform if before_perform raises Resque::Job::DontPerform" do
5151
result = perform_job(BeforePerformJobAborts, history=[])
5252
assert_equal false, result, "perform returned false"
5353
assert_equal history, [:before_perform], "Only before_perform was run"
5454
end
5555
end
5656

57-
context "Resque::Job after_perform" do
57+
describe "Resque::Job after_perform" do
5858
include PerformJob
5959

6060
class ::AfterPerformJob
@@ -66,7 +66,7 @@ def self.after_perform_record_history(history)
6666
end
6767
end
6868

69-
test "it runs after_perform after perform" do
69+
it "it runs after_perform after perform" do
7070
result = perform_job(AfterPerformJob, history=[])
7171
assert_equal true, result, "perform returned true"
7272
assert_equal history, [:perform, :after_perform]
@@ -82,7 +82,7 @@ def self.after_perform_fail_job(history)
8282
end
8383
end
8484

85-
test "raises an error but has already performed if after_perform fails" do
85+
it "raises an error but has already performed if after_perform fails" do
8686
history = []
8787
assert_raises StandardError do
8888
perform_job(AfterPerformJobFails, history)
@@ -91,7 +91,7 @@ def self.after_perform_fail_job(history)
9191
end
9292
end
9393

94-
context "Resque::Job around_perform" do
94+
describe "Resque::Job around_perform" do
9595
include PerformJob
9696

9797
class ::AroundPerformJob
@@ -105,7 +105,7 @@ def self.around_perform_record_history(history)
105105
end
106106
end
107107

108-
test "it runs around_perform then yields in order to perform" do
108+
it "it runs around_perform then yields in order to perform" do
109109
result = perform_job(AroundPerformJob, history=[])
110110
assert_equal true, result, "perform returned true"
111111
assert_equal history, [:start_around_perform, :perform, :finish_around_perform]
@@ -123,7 +123,7 @@ def self.around_perform_fail(history)
123123
end
124124
end
125125

126-
test "raises an error and does not perform if around_perform fails before yielding" do
126+
it "raises an error and does not perform if around_perform fails before yielding" do
127127
history = []
128128
assert_raises StandardError do
129129
perform_job(AroundPerformJobFailsBeforePerforming, history)
@@ -147,7 +147,7 @@ def self.around_perform_fail_in_yield(history)
147147
end
148148
end
149149

150-
test "raises an error but may handle exceptions if perform fails" do
150+
it "raises an error but may handle exceptions if perform fails" do
151151
history = []
152152
assert_raises StandardError do
153153
perform_job(AroundPerformJobFailsWhilePerforming, history)
@@ -165,15 +165,15 @@ def self.around_perform_dont_yield(history)
165165
end
166166
end
167167

168-
test "around_perform is not required to yield" do
168+
it "around_perform is not required to yield" do
169169
history = []
170170
result = perform_job(AroundPerformJobDoesNotHaveToYield, history)
171171
assert_equal false, result, "perform returns false"
172172
assert_equal history, [:start_around_perform, :finish_around_perform], "perform was not run"
173173
end
174174
end
175175

176-
context "Resque::Job on_failure" do
176+
describe "Resque::Job on_failure" do
177177
include PerformJob
178178

179179
class ::FailureJobThatDoesNotFail
@@ -185,7 +185,7 @@ def self.on_failure_record_failure(exception, history)
185185
end
186186
end
187187

188-
test "it does not call on_failure if no failures occur" do
188+
it "it does not call on_failure if no failures occur" do
189189
result = perform_job(FailureJobThatDoesNotFail, history=[])
190190
assert_equal true, result, "perform returned true"
191191
assert_equal history, [:perform]
@@ -201,7 +201,7 @@ def self.on_failure_record_failure(exception, history)
201201
end
202202
end
203203

204-
test "it calls on_failure with the exception and then re-raises the exception" do
204+
it "it calls on_failure with the exception and then re-raises the exception" do
205205
history = []
206206
assert_raises StandardError do
207207
perform_job(FailureJobThatFails, history)
@@ -219,7 +219,7 @@ def self.on_failure_record_failure(exception, history)
219219
end
220220
end
221221

222-
test "it calls on_failure even with bad exceptions" do
222+
it "it calls on_failure even with bad exceptions" do
223223
history = []
224224
assert_raises SyntaxError do
225225
perform_job(FailureJobThatFailsBadly, history)
@@ -228,7 +228,7 @@ def self.on_failure_record_failure(exception, history)
228228
end
229229
end
230230

231-
context "Resque::Job after_enqueue" do
231+
describe "Resque::Job after_enqueue" do
232232
include PerformJob
233233

234234
class ::AfterEnqueueJob
@@ -241,7 +241,7 @@ def self.perform(history)
241241
end
242242
end
243243

244-
test "the after enqueue hook should run" do
244+
it "the after enqueue hook should run" do
245245
history = []
246246
@worker = Resque::Worker.new(:jobs)
247247
Resque.enqueue(AfterEnqueueJob, history)
@@ -251,7 +251,7 @@ def self.perform(history)
251251
end
252252

253253

254-
context "Resque::Job before_enqueue" do
254+
describe "Resque::Job before_enqueue" do
255255
include PerformJob
256256

257257
class ::BeforeEnqueueJob
@@ -274,23 +274,23 @@ def self.perform(history)
274274
end
275275
end
276276

277-
test "the before enqueue hook should run" do
277+
it "the before enqueue hook should run" do
278278
history = []
279279
@worker = Resque::Worker.new(:jobs)
280280
assert Resque.enqueue(BeforeEnqueueJob, history)
281281
@worker.work(0)
282282
assert_equal history, [:before_enqueue], "before_enqueue was not run"
283283
end
284284

285-
test "a before enqueue hook that returns false should prevent the job from getting queued" do
285+
it "a before enqueue hook that returns false should prevent the job from getting queued" do
286286
history = []
287287
@worker = Resque::Worker.new(:jobs)
288288
assert_nil Resque.enqueue(BeforeEnqueueJobAbort, history)
289289
assert_equal 0, Resque.size(:jobs)
290290
end
291291
end
292292

293-
context "Resque::Job after_dequeue" do
293+
describe "Resque::Job after_dequeue" do
294294
include PerformJob
295295

296296
class ::AfterDequeueJob
@@ -303,7 +303,7 @@ def self.perform(history)
303303
end
304304
end
305305

306-
test "the after dequeue hook should run" do
306+
it "the after dequeue hook should run" do
307307
history = []
308308
@worker = Resque::Worker.new(:jobs)
309309
Resque.dequeue(AfterDequeueJob, history)
@@ -313,7 +313,7 @@ def self.perform(history)
313313
end
314314

315315

316-
context "Resque::Job before_dequeue" do
316+
describe "Resque::Job before_dequeue" do
317317
include PerformJob
318318

319319
class ::BeforeDequeueJob
@@ -336,21 +336,21 @@ def self.perform(history)
336336
end
337337
end
338338

339-
test "the before dequeue hook should run" do
339+
it "the before dequeue hook should run" do
340340
history = []
341341
@worker = Resque::Worker.new(:jobs)
342342
Resque.dequeue(BeforeDequeueJob, history)
343343
@worker.work(0)
344344
assert_equal history, [:before_dequeue], "before_dequeue was not run"
345345
end
346346

347-
test "a before dequeue hook that returns false should prevent the job from getting dequeued" do
347+
it "a before dequeue hook that returns false should prevent the job from getting dequeued" do
348348
history = []
349349
assert_equal nil, Resque.dequeue(BeforeDequeueJobAbort, history)
350350
end
351351
end
352352

353-
context "Resque::Job all hooks" do
353+
describe "Resque::Job all hooks" do
354354
include PerformJob
355355

356356
class ::VeryHookyJob
@@ -373,7 +373,7 @@ def self.on_failure_record_history(exception, history)
373373
end
374374
end
375375

376-
test "the complete hook order" do
376+
it "the complete hook order" do
377377
result = perform_job(VeryHookyJob, history=[])
378378
assert_equal true, result, "perform returned true"
379379
assert_equal history, [
@@ -406,7 +406,7 @@ def self.on_failure_record_history(exception, history)
406406
end
407407
end
408408

409-
test "the complete hook order with a failure at the last minute" do
409+
it "the complete hook order with a failure at the last minute" do
410410
history = []
411411
assert_raises StandardError do
412412
perform_job(VeryHookyJobThatFails, history)

0 commit comments

Comments
 (0)