Sha256: c893849156501a9146a839aaab0aba16f8320ad4b6551c8cceb6bb4f9888b1d2

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

require "test_helper"

# To allow sidekiq error handlers to be registered, sidekiq must be in
# "server mode". This mode is triggered by loading sidekiq/cli. Note this
# has to be loaded before exception_notification/sidekiq.
require "sidekiq/cli"

require "exception_notification/sidekiq"

class MockSidekiqServer
  include ::Sidekiq::ExceptionHandler
end

class SidekiqTest < ActiveSupport::TestCase
  setup do
    @_original_sidekiq_logger = Sidekiq::Logging.logger

    # Silence sidekiq warning to stdout
    Sidekiq::Logging.logger = nil
  end

  test "should call notify_exception when sidekiq raises an error" do
    server = MockSidekiqServer.new
    message = Hash.new
    exception = RuntimeError.new

    ExceptionNotifier.expects(:notify_exception).with(
      exception,
      :data => { :sidekiq => message }
    )

    server.handle_exception(exception, message)
  end

  teardown do
    Sidekiq::Logging.logger = @_original_sidekiq_logger
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exception_notification-4.3.0 test/exception_notifier/sidekiq_test.rb
exception_notification-4.2.2 test/exception_notifier/sidekiq_test.rb
exception_notification-4.2.1 test/exception_notifier/sidekiq_test.rb