Skip to content

Instantly share code, notes, and snippets.

@collinschaafsma
Created October 11, 2010 16:13
Show Gist options
  • Save collinschaafsma/620776 to your computer and use it in GitHub Desktop.
Save collinschaafsma/620776 to your computer and use it in GitHub Desktop.
require "spec/spec_helper"
class Bad
def self.deliver_message
raise "It broke."
end
end
class BadJob
def perform
Bad.deliver_message
end
end
class Good
def self.deliver_message
'All good in the hood!'
end
end
class GoodJob
def perform
Good.deliver_message
end
end
describe Delayed do
it "should notify Hoptoad" do
# should receive this twice because Delayed::Worker.max_attempts = 2
HoptoadNotifier.should_receive(:notify).twice.with(instance_of(RuntimeError))
Delayed::Job.enqueue BadJob.new
Delayed::Worker.new.work_off
end
it "should not notify Hoptoad" do
HoptoadNotifier.should_not_receive(:notify)
Delayed::Job.enqueue GoodJob.new
Delayed::Worker.new.work_off
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment