Sha256: 267f0ba841138658dc307d7099580eda2fde2be9ba8b7344d6ff039acfc68abe

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'Bugsnag::Que', :order => :defined do
  before do
    unless defined?(::Que)
      @mocked_que = true
      class ::Que
      end
    end
  end

  it "should create and register a que handler" do
    error = RuntimeError.new("oops")
    job = double('que_job')
    expect(job).to receive(:dup).and_return({
      :error_count => 0,
      :job_class => 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper',
      :args => [{"queue_name" => "foo", "arguments" => "bar"}],
      :job_id => "ID"
    })

    report = double('report')
    expect(Bugsnag).to receive(:notify).with(error, true).and_yield(report)
    expect(report).to receive(:add_tab).with(:job, {
      :error_count => 1,
      :job_class => 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper',
      :args => [{"queue_name" => "foo", "arguments" => "bar"}],
      :job_id => "ID",
      :wrapper_job_class => 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper',
      :wrapper_job_id => "ID",
      :queue => "foo",
      :args => "bar"
    })
    expect(report).to receive(:severity=).with("error")
    expect(report).to receive(:severity_reason=).with({
      :type => Bugsnag::Report::UNHANDLED_EXCEPTION_MIDDLEWARE,
      :attributes => {
        :framework => 'Que'
      }
    })

    allow(Que).to receive(:respond_to?).with(:error_notifier=).and_return(true)
    config = double('config')
    allow(Bugsnag).to receive(:configuration).and_return(config)
    expect(config).to receive(:app_type)
    expect(config).to receive(:app_type=).with('que')
    allow(config).to receive(:clear_request_data)
    expect(Que).to receive(:error_notifier=) do |handler|
      handler.call(error, job)
    end

    #Kick off
    load './lib/bugsnag/integrations/que.rb'
  end

  after do
    Object.send(:remove_const, :Que) if @mocked_que
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bugsnag-6.11.1 spec/integrations/que_spec.rb
bugsnag-6.11.0 spec/integrations/que_spec.rb
bugsnag-6.10.0 spec/integrations/que_spec.rb
bugsnag-6.9.0 spec/integrations/que_spec.rb
bugsnag-6.8.0 spec/integrations/que_spec.rb
bugsnag-6.7.3 spec/integrations/que_spec.rb
bugsnag-6.7.2 spec/integrations/que_spec.rb
bugsnag-6.7.1 spec/integrations/que_spec.rb
bugsnag-6.7.0 spec/integrations/que_spec.rb
bugsnag-6.6.4 spec/integrations/que_spec.rb
bugsnag-6.6.3 spec/integrations/que_spec.rb
bugsnag-6.6.2 spec/integrations/que_spec.rb