Skip to content

Instantly share code, notes, and snippets.

@fabioyamate
Last active December 18, 2015 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabioyamate/5823247 to your computer and use it in GitHub Desktop.
Save fabioyamate/5823247 to your computer and use it in GitHub Desktop.
resque failures
describe "job failures" do
it 'retries with limited attempts' do
require 'resque/failure/redis'
Resque.unstub(:enqueue)
Resque::Failure::MultipleWithRetrySuppression.classes = [Resque::Failure::Redis]
Resque::Failure.backend = Resque::Failure::MultipleWithRetrySuppression
JobWithError = Class.new do
@queue = "test"
extend Resque::Plugins::Retry
def self.perform
raise ArgumentError
end
end
Resque.enqueue(JobWithError)
worker = Resque::Worker.new("test")
process_job(worker)
Resque::Failure.count.should be_zero
process_job(worker)
Resque::Failure.count.should == 1
should_have_no_jobs(worker)
end
def should_have_no_jobs(worker)
worker.reserve.should be_nil
end
def process_job(worker)
job = worker.reserve
worker.perform(job)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment