Sha256: d55f47155f2a068b3469d84fa9cbcbc3013407b51622f9f65c6bc346ed00ec5b

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

require 'roqua/support/errors'

describe 'Error reporting' do
  let(:exception) do
    Exception.new('exception_message').tap do |exception|
      exception.set_backtrace ['back', 'trace', 'lines']
    end
  end

  let(:logstream)  { StringIO.new }
  let(:logger)     { Logger.new(logstream) }
  let(:logwrapper) { Roqua::LogWrapper.new(logger) }

  before do
    Roqua.logger = logwrapper
  end

  it 'sends notifications to the eventlog' do
    Roqua.logger.should_receive(:error).with('roqua.exception',
                                             class_name: 'Exception',
                                             message: 'exception_message',
                                             backtrace: ['back', 'trace', 'lines'],
                                             parameters: {})
    Roqua::Support::Errors.report exception
  end

  it 'sends notifications to airbrake' do
    stub_const("Airbrake", double("Airbrake"))
    Airbrake.should_receive(:notify_or_ignore).with(exception, parameters: {})
    Roqua::Support::Errors.report exception
  end

  it 'sends notifications to appsignal' do
    stub_const("Appsignal", double("Appsignal"))
    Appsignal.should_receive(:send_exception_with_tags).with(exception, parameters: {})
    Roqua::Support::Errors.report exception
  end

  it 'supports default extra params' do
    Roqua::Support::Errors.extra_parameters = {organization: 'some_org'}
    Roqua.logger.should_receive(:error).with('roqua.exception',
                                             class_name: 'Exception',
                                             message: 'exception_message',
                                             backtrace: ['back', 'trace', 'lines'],
                                             parameters: {organization: 'some_org'})
    Roqua::Support::Errors.report exception
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roqua-support-0.1.2.1 spec/roqua/support/errors_spec.rb
roqua-support-0.1.2 spec/roqua/support/errors_spec.rb