Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Consistent operation.
  • Loading branch information
usiegj00 committed Oct 9, 2011
2 parents f7e9d82 + 64464ed commit 9007558
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions features/rake.feature
Expand Up @@ -6,6 +6,10 @@ Feature: Use the Gem to catch errors in a Rake application
When I run rake with airbrake
Then Airbrake should catch the exception

Scenario: Falling back to default handler before Airbrake is configured
When I run rake with airbrake not yet configured
Then Airbrake should not catch the exception

Scenario: Disabling Rake exception catcher
When I run rake with airbrake disabled
Then Airbrake should not catch the exception
Expand Down
11 changes: 11 additions & 0 deletions features/support/rake/Rakefile
Expand Up @@ -36,13 +36,24 @@ task :airbrake_autodetect_not_from_terminal do
raise_exception
end

task :airbrake_not_yet_configured do
Airbrake.configuration.rescue_rake_exceptions = true
stub_tty_output(true)
stub_empty_sender
raise_exception
end

module Airbrake
def self.notify(*args)
# TODO if you need to check more params, you'll have to use json.dump or something
$stderr.puts "airbrake #{args[1][:component]}"
end
end

def stub_empty_sender
Airbrake.sender = nil
end

def stub_tty_output(value)
Rake.application.instance_eval do
@tty_output_stub = value
Expand Down
2 changes: 1 addition & 1 deletion lib/airbrake/rake_handler.rb
Expand Up @@ -9,7 +9,7 @@ def self.included(klass)
end

def display_error_message_with_airbrake(ex)
if Airbrake.configuration &&
if Airbrake.sender && Airbrake.configuration &&
(Airbrake.configuration.rescue_rake_exceptions ||
(Airbrake.configuration.rescue_rake_exceptions===nil && !self.tty_output?))

Expand Down
1 change: 1 addition & 0 deletions lib/airbrake/user_informer.rb
Expand Up @@ -16,6 +16,7 @@ def call(env)
body.each do |chunk|
new_body << chunk.gsub("<!-- AIRBRAKE ERROR -->", replace)
end
body.close if body.respond_to?(:close)
headers['Content-Length'] = new_body.sum(&:length).to_s
body = new_body
end
Expand Down

0 comments on commit 9007558

Please sign in to comment.