Skip to content
Browse files

remove deprecated HoptoadNotifier

  • Loading branch information...
1 parent 8ee1fa6 commit 62e44d6603b0883eba0078615cd1189c7056b60a @shime shime committed Aug 4, 2012
Showing with 78 additions and 5 deletions.
  1. +3 −5 lib/girl_friday/error_handler.rb
  2. +15 −0 test/helper.rb
  3. +60 −0 test/test_error_handler.rb
View
8 lib/girl_friday/error_handler.rb
@@ -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
View
15 test/helper.rb
@@ -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
View
60 test/test_error_handler.rb
@@ -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

0 comments on commit 62e44d6

Please sign in to comment.
Something went wrong with that request. Please try again.