Skip to content

Commit

Permalink
add a scenario for ignoring rake exceptions [#223]
Browse files Browse the repository at this point in the history
  • Loading branch information
shime committed Jun 25, 2013
1 parent 010f7e2 commit 327ebe1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions features/rake.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions features/support/rake/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

0 comments on commit 327ebe1

Please sign in to comment.