test/job_hooks_test.rb in resque-mongo-1.8.1 vs test/job_hooks_test.rb in resque-mongo-1.9.8.1
- old
+ new
@@ -1,11 +1,11 @@
require File.dirname(__FILE__) + '/test_helper'
context "Resque::Job before_perform" do
include PerformJob
- class BeforePerformJob
+ class ::BeforePerformJob
def self.before_perform_record_history(history)
history << :before_perform
end
def self.perform(history)
@@ -17,11 +17,11 @@
result = perform_job(BeforePerformJob, history=[])
assert_equal true, result, "perform returned true"
assert_equal history, [:before_perform, :perform]
end
- class BeforePerformJobFails
+ class ::BeforePerformJobFails
def self.before_perform_fail_job(history)
history << :before_perform
raise StandardError
end
def self.perform(history)
@@ -35,11 +35,11 @@
perform_job(BeforePerformJobFails, history)
end
assert_equal history, [:before_perform], "Only before_perform was run"
end
- class BeforePerformJobAborts
+ class ::BeforePerformJobAborts
def self.before_perform_abort(history)
history << :before_perform
raise Resque::Job::DontPerform
end
def self.perform(history)
@@ -55,11 +55,11 @@
end
context "Resque::Job after_perform" do
include PerformJob
- class AfterPerformJob
+ class ::AfterPerformJob
def self.perform(history)
history << :perform
end
def self.after_perform_record_history(history)
history << :after_perform
@@ -70,11 +70,11 @@
result = perform_job(AfterPerformJob, history=[])
assert_equal true, result, "perform returned true"
assert_equal history, [:perform, :after_perform]
end
- class AfterPerformJobFails
+ class ::AfterPerformJobFails
def self.perform(history)
history << :perform
end
def self.after_perform_fail_job(history)
history << :after_perform
@@ -92,11 +92,11 @@
end
context "Resque::Job around_perform" do
include PerformJob
- class AroundPerformJob
+ class ::AroundPerformJob
def self.perform(history)
history << :perform
end
def self.around_perform_record_history(history)
history << :start_around_perform
@@ -109,11 +109,11 @@
result = perform_job(AroundPerformJob, history=[])
assert_equal true, result, "perform returned true"
assert_equal history, [:start_around_perform, :perform, :finish_around_perform]
end
- class AroundPerformJobFailsBeforePerforming
+ class ::AroundPerformJobFailsBeforePerforming
def self.perform(history)
history << :perform
end
def self.around_perform_fail(history)
history << :start_around_perform
@@ -129,11 +129,11 @@
perform_job(AroundPerformJobFailsBeforePerforming, history)
end
assert_equal history, [:start_around_perform], "Only part of around_perform was run"
end
- class AroundPerformJobFailsWhilePerforming
+ class ::AroundPerformJobFailsWhilePerforming
def self.perform(history)
history << :perform
raise StandardError
end
def self.around_perform_fail_in_yield(history)
@@ -153,11 +153,11 @@
perform_job(AroundPerformJobFailsWhilePerforming, history)
end
assert_equal history, [:start_around_perform, :perform, :ensure_around_perform], "Only part of around_perform was run"
end
- class AroundPerformJobDoesNotHaveToYield
+ class ::AroundPerformJobDoesNotHaveToYield
def self.perform(history)
history << :perform
end
def self.around_perform_dont_yield(history)
history << :start_around_perform
@@ -174,11 +174,11 @@
end
context "Resque::Job on_failure" do
include PerformJob
- class FailureJobThatDoesNotFail
+ class ::FailureJobThatDoesNotFail
def self.perform(history)
history << :perform
end
def self.on_failure_record_failure(exception, history)
history << exception.message
@@ -189,11 +189,11 @@
result = perform_job(FailureJobThatDoesNotFail, history=[])
assert_equal true, result, "perform returned true"
assert_equal history, [:perform]
end
- class FailureJobThatFails
+ class ::FailureJobThatFails
def self.perform(history)
history << :perform
raise StandardError, "oh no"
end
def self.on_failure_record_failure(exception, history)
@@ -207,11 +207,11 @@
perform_job(FailureJobThatFails, history)
end
assert_equal history, [:perform, "oh no"]
end
- class FailureJobThatFailsBadly
+ class ::FailureJobThatFailsBadly
def self.perform(history)
history << :perform
raise SyntaxError, "oh no"
end
def self.on_failure_record_failure(exception, history)
@@ -229,11 +229,11 @@
end
context "Resque::Job all hooks" do
include PerformJob
- class VeryHookyJob
+ class ::VeryHookyJob
def self.before_perform_record_history(history)
history << :before_perform
end
def self.around_perform_record_history(history)
history << :start_around_perform
@@ -261,10 +261,10 @@
:finish_around_perform,
:after_perform
]
end
- class VeryHookyJobThatFails
+ class ::VeryHookyJobThatFails
def self.before_perform_record_history(history)
history << :before_perform
end
def self.around_perform_record_history(history)
history << :start_around_perform