Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #58 from shime/master

remove deprecated HoptoadNotifier
  • Loading branch information...
commit f03572d5d2b1e03858e2888a957b73913d3274fe 2 parents 8ee1fa6 + 62e44d6
Mike Perham authored
8 lib/girl_friday/error_handler.rb
View
@@ -3,7 +3,7 @@ module ErrorHandler
def self.default
handlers = [Stderr]
- handlers << Hoptoad if defined?(HoptoadNotifier)
+ handlers << Airbrake if defined?(::Airbrake)
handlers
end
@@ -14,12 +14,10 @@ def handle(ex)
end
end
- class Hoptoad
+ class Airbrake
def handle(ex)
- HoptoadNotifier.notify_or_ignore(ex)
+ ::Airbrake.notify_or_ignore(ex)
end
end
- Airbrake = Hoptoad
-
end
end
15 test/helper.rb
View
@@ -40,3 +40,18 @@ def async_test(time=0.5)
end
end
+
+module Faker
+ def initialize
+ @number_of_calls = 0
+ end
+
+ def number_of_calls
+ @number_of_calls
+ end
+
+
+ def count(*args,&blk)
+ @number_of_calls += 1
+ end
+end
60 test/test_error_handler.rb
View
@@ -0,0 +1,60 @@
+require 'helper'
+
+
+class TestErrorHandler < MiniTest::Unit::TestCase
+ Stderr = GirlFriday::ErrorHandler::Stderr
+ Airbrake = GirlFriday::ErrorHandler::Airbrake
+
+ class FakeStderr
+ include Faker
+ def flush
+ "WOOSH!"
+ end
+ alias_method :puts, :count
+ alias_method :write, :count
+ end
+
+ class FakeAirbrake
+ include Faker
+ alias_method :notify_or_ignore, :count
+ end
+
+ class FakeError
+ def backtrace
+ %w(
+ We're no strangers to love
+ You know the rules and so do I
+ A full commitment's what I'm thinking of
+ You wouldn't get this from any other guy
+ I just wanna tell you how I'm feeling
+ Gotta make you understand
+ )
+ end
+ end
+
+ def handler
+ GirlFriday::ErrorHandler
+ end
+
+ def test_default
+ assert_equal [Stderr], handler.default
+
+ Object.const_set("Airbrake","super cool error catcher")
+ assert_equal [Stderr,Airbrake], handler.default
+ Object.send(:remove_const,:Airbrake)
+ end
+
+ def test_stderr
+ $stderr = FakeStderr.new
+ Stderr.new.handle(FakeError.new)
+ assert_equal 2, $stderr.number_of_calls
+ end
+
+ def test_airbrake
+ airbrake = FakeAirbrake.new
+ Object.const_set("Airbrake", airbrake)
+ Airbrake.new.handle(FakeError.new)
+ assert_equal 1, airbrake.number_of_calls
+ Object.send(:remove_const,:Airbrake)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.