Skip to content

Commit

Permalink
Hoptoad backend has always been optional - don't require hoptoad_noti…
Browse files Browse the repository at this point in the history
…fier gem
  • Loading branch information
defunkt committed May 16, 2011
1 parent f56fa99 commit 3a49aa9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
6 changes: 0 additions & 6 deletions Gemfile.lock
Expand Up @@ -2,7 +2,6 @@ PATH
remote: .
specs:
resque (1.15.0)
hoptoad_notifier (~> 2.4.9)
json (>= 1.4.6, < 1.6)
redis-namespace (>= 0.10.0)
sinatra (>= 0.9.2)
Expand All @@ -11,11 +10,6 @@ PATH
GEM
remote: http://rubygems.org/
specs:
activesupport (3.0.7)
builder (3.0.0)
hoptoad_notifier (2.4.9)
activesupport
builder
json (1.5.1)
leftright (0.9.1)
mocha (0.9.7)
Expand Down
10 changes: 7 additions & 3 deletions lib/resque/failure/hoptoad.rb
@@ -1,4 +1,8 @@
require 'hoptoad_notifier'
begin
require 'hoptoad_notifier'
rescue LoadError
raise "Can't find 'hoptoad_notifier' gem. Please add it to your Gemfile or install it."
end

module Resque
module Failure
Expand All @@ -13,11 +17,11 @@ module Failure
#
# Once you've configured resque to use the Hoptoad failure backend,
# you'll want to setup an initializer to configure the Hoptoad.
#
#
# HoptoadNotifier.configure do |config|
# config.api_key = 'your_key_here'
# end
# For more information see https://github.com/thoughtbot/hoptoad_notifier
# For more information see https://github.com/thoughtbot/hoptoad_notifier
class Hoptoad < Base

def self.count
Expand Down
2 changes: 0 additions & 2 deletions resque.gemspec
Expand Up @@ -25,8 +25,6 @@ Gem::Specification.new do |s|
s.add_dependency "vegas", "~> 0.1.2"
s.add_dependency "sinatra", ">= 0.9.2"
s.add_dependency "json", ">= 1.4.6", "< 1.6"
s.add_dependency "hoptoad_notifier","~> 2.4.9"


s.description = <<description
Resque is a Redis-backed Ruby library for creating background jobs,
Expand Down
34 changes: 18 additions & 16 deletions test/hoptoad_test.rb
@@ -1,23 +1,25 @@
require 'test_helper'
require 'resque/failure/hoptoad'
require 'mocha'
require 'hoptoad_notifier'

context "Hoptoad" do

test "should be notified of an error" do
exception = StandardError.new("BOOM")
worker = Resque::Worker.new(:test)
queue = "test"
payload = {'class' => Object, 'args' => 66}
begin
require 'hoptoad_notifier'
rescue LoadError
warn "Install hoptoad_notifier gem to run Hoptoad tests."
end

HoptoadNotifier.expects(:notify_or_ignore).with(
exception,
:parameters => {:payload_class => 'Object', :payload_args => '66'})
if defined? HoptoadNotifier
context "Hoptoad" do
test "should be notified of an error" do
exception = StandardError.new("BOOM")
worker = Resque::Worker.new(:test)
queue = "test"
payload = {'class' => Object, 'args' => 66}

backend = Resque::Failure::Hoptoad.new(exception, worker, queue, payload)
backend.save
HoptoadNotifier.expects(:notify_or_ignore).with(
exception,
:parameters => {:payload_class => 'Object', :payload_args => '66'})

backend = Resque::Failure::Hoptoad.new(exception, worker, queue, payload)
backend.save
end
end

end

0 comments on commit 3a49aa9

Please sign in to comment.