Created
October 11, 2010 16:13
-
-
Save collinschaafsma/620776 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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