Skip to content

Commit 3a49aa9

Browse files
committed
Hoptoad backend has always been optional - don't require hoptoad_notifier gem
1 parent f56fa99 commit 3a49aa9

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

Gemfile.lock

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ PATH
22
remote: .
33
specs:
44
resque (1.15.0)
5-
hoptoad_notifier (~> 2.4.9)
65
json (>= 1.4.6, < 1.6)
76
redis-namespace (>= 0.10.0)
87
sinatra (>= 0.9.2)
@@ -11,11 +10,6 @@ PATH
1110
GEM
1211
remote: http://rubygems.org/
1312
specs:
14-
activesupport (3.0.7)
15-
builder (3.0.0)
16-
hoptoad_notifier (2.4.9)
17-
activesupport
18-
builder
1913
json (1.5.1)
2014
leftright (0.9.1)
2115
mocha (0.9.7)

lib/resque/failure/hoptoad.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
require 'hoptoad_notifier'
1+
begin
2+
require 'hoptoad_notifier'
3+
rescue LoadError
4+
raise "Can't find 'hoptoad_notifier' gem. Please add it to your Gemfile or install it."
5+
end
26

37
module Resque
48
module Failure
@@ -13,11 +17,11 @@ module Failure
1317
#
1418
# Once you've configured resque to use the Hoptoad failure backend,
1519
# you'll want to setup an initializer to configure the Hoptoad.
16-
#
20+
#
1721
# HoptoadNotifier.configure do |config|
1822
# config.api_key = 'your_key_here'
1923
# end
20-
# For more information see https://github.com/thoughtbot/hoptoad_notifier
24+
# For more information see https://github.com/thoughtbot/hoptoad_notifier
2125
class Hoptoad < Base
2226

2327
def self.count

resque.gemspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ Gem::Specification.new do |s|
2525
s.add_dependency "vegas", "~> 0.1.2"
2626
s.add_dependency "sinatra", ">= 0.9.2"
2727
s.add_dependency "json", ">= 1.4.6", "< 1.6"
28-
s.add_dependency "hoptoad_notifier","~> 2.4.9"
29-
3028

3129
s.description = <<description
3230
Resque is a Redis-backed Ruby library for creating background jobs,

test/hoptoad_test.rb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
require 'test_helper'
2-
require 'resque/failure/hoptoad'
3-
require 'mocha'
4-
require 'hoptoad_notifier'
52

6-
context "Hoptoad" do
7-
8-
test "should be notified of an error" do
9-
exception = StandardError.new("BOOM")
10-
worker = Resque::Worker.new(:test)
11-
queue = "test"
12-
payload = {'class' => Object, 'args' => 66}
3+
begin
4+
require 'hoptoad_notifier'
5+
rescue LoadError
6+
warn "Install hoptoad_notifier gem to run Hoptoad tests."
7+
end
138

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

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

21+
backend = Resque::Failure::Hoptoad.new(exception, worker, queue, payload)
22+
backend.save
23+
end
2124
end
22-
2325
end

0 commit comments

Comments
 (0)