From 327ebe1bbce4a6e4e3cc0dee314ea280f194efad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= Date: Tue, 25 Jun 2013 14:08:04 +0200 Subject: [PATCH] add a scenario for ignoring rake exceptions [#223] --- features/rake.feature | 4 ++++ features/support/rake/Rakefile | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/features/rake.feature b/features/rake.feature index cc06a1f0e..d92697a37 100644 --- a/features/rake.feature +++ b/features/rake.feature @@ -3,6 +3,10 @@ Feature: Use the Gem to catch errors in a Rake application Background: Given I've prepared the Rakefile + Scenario: Ignoring exceptions + When I run rake with airbrake ignored + Then Airbrake should not catch the exception + Scenario: Catching exceptions in Rake When I run rake with airbrake Then Airbrake should catch the exception diff --git a/features/support/rake/Rakefile b/features/support/rake/Rakefile index 07b230085..0bb574163 100644 --- a/features/support/rake/Rakefile +++ b/features/support/rake/Rakefile @@ -5,7 +5,10 @@ require 'rubygems' require 'airbrake' require 'airbrake/rake_handler' +class IgnoredException < StandardError; end + Airbrake.configure do |c| + c.ignore_rake_only = ["IgnoredException"] end # Should catch exception @@ -22,6 +25,13 @@ task :airbrake_disabled do raise_exception end +# Should ignore the exception +task :airbrake_ignored do + Airbrake.configuration.rescue_rake_exceptions = true + stub_tty_output(true) + raise_exception(IgnoredException) +end + # Should not catch exception as tty_output is true task :airbrake_autodetect_from_terminal do Airbrake.configuration.rescue_rake_exceptions = nil @@ -44,8 +54,8 @@ task :airbrake_not_yet_configured do end module Airbrake - def self.notify_or_ignore(*args) - $stderr.puts "[airbrake] #{args[1][:component]}" + def self.send_notice(notice) + $stderr.puts "[airbrake] #{notice.component}" end end @@ -62,6 +72,6 @@ def stub_tty_output(value) end end -def raise_exception - raise 'TEST' +def raise_exception(exception_class = StandardError) + raise exception_class.new('TEST') end