Sha256: 826d3284ec596ba658e14a4c4c8dfd7fcca949ed52d193daa6ee003397bf5a39

Contents?: true

Size: 1.64 KB

Versions: 21

Compression:

Stored size: 1.64 KB

Contents

# A test harness for RakeHandler
#
require 'rake'
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
task :airbrake do
  Airbrake.configuration.rescue_rake_exceptions = true
  stub_tty_output(true)
  raise_exception 
end

# Should not catch exception
task :airbrake_disabled do
  Airbrake.configuration.rescue_rake_exceptions = false
  stub_tty_output(true)
  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
  stub_tty_output(true) 
  raise_exception 
end

# Should catch exception as tty_output is false
task :airbrake_autodetect_not_from_terminal do
  Airbrake.configuration.rescue_rake_exceptions = nil
  stub_tty_output(false) 
  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.send_notice(notice)
    $stderr.puts "[airbrake] #{notice.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
    def tty_output?
      @tty_output_stub
    end
  end
end

def raise_exception(exception_class = StandardError)
  raise exception_class.new('TEST')
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
airbrakeV4rails5-4.3.8 features/support/rake/Rakefile
airbrake-4.3.8 features/support/rake/Rakefile
airbrake-4.3.7 features/support/rake/Rakefile
airbrake-4.3.6 features/support/rake/Rakefile
airbrake-4.3.5 features/support/rake/Rakefile
airbrake-4.3.4 features/support/rake/Rakefile
airbrake-4.3.3 features/support/rake/Rakefile
airbrake-4.3.2 features/support/rake/Rakefile
airbrake-4.3.1 features/support/rake/Rakefile
airbrake-4.3.0 features/support/rake/Rakefile
airbrake-4.2.1 features/support/rake/Rakefile
airbrake-4.2.0 features/support/rake/Rakefile
airbrake-4.1.0 features/support/rake/Rakefile
airbrake-4.0.0 features/support/rake/Rakefile
airbrake-3.2.1 features/support/rake/Rakefile
airbrake-3.2.0 features/support/rake/Rakefile
airbrake-3.1.17 features/support/rake/Rakefile
airbrake-3.1.16 features/support/rake/Rakefile
airbrake-3.1.15 features/support/rake/Rakefile
airbrake-3.1.14 features/support/rake/Rakefile