Sha256: b51a5ed2174bb2bc23a01d58cdb88fd5d1a9f5c6284be8f6dc3b5b191104d01c

Contents?: true

Size: 1.42 KB

Versions: 11

Compression:

Stored size: 1.42 KB

Contents

require 'helper'

RSpec.describe Delayed::Plugins::Instrumentation do
  let!(:job) { Delayed::Job.enqueue SimpleJob.new, priority: 13, queue: 'test' }

  it 'emits delayed.job.run' do
    expect { Delayed::Worker.new.work_off }.to emit_notification('delayed.job.run').with_payload(
      job_name: 'SimpleJob',
      priority: 13,
      queue: 'test',
      table: 'delayed_jobs',
      database: current_database,
      database_adapter: current_adapter,
      job: job,
    )
  end

  context 'when the job errors' do
    let!(:job) { Delayed::Job.enqueue ErrorJob.new, priority: 7, queue: 'foo' }

    it 'emits delayed.job.error' do
      expect { Delayed::Worker.new.work_off }.to emit_notification('delayed.job.error').with_payload(
        job_name: 'ErrorJob',
        priority: 7,
        queue: 'foo',
        table: 'delayed_jobs',
        database: current_database,
        database_adapter: current_adapter,
        job: job,
      )
    end
  end

  context 'when the job fails' do
    let!(:job) { Delayed::Job.enqueue FailureJob.new, priority: 3, queue: 'bar' }

    it 'emits delayed.job.failure' do
      expect { Delayed::Worker.new.work_off }.to emit_notification('delayed.job.failure').with_payload(
        job_name: 'FailureJob',
        priority: 3,
        queue: 'bar',
        table: 'delayed_jobs',
        database: current_database,
        database_adapter: current_adapter,
        job: job,
      )
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
delayed-0.5.5 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.5.4 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.5.3 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.5.2 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.5.1 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.5.0 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.4.0 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.3.0 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.2.0 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.1.1 spec/delayed/plugins/instrumentation_spec.rb
delayed-0.1.0 spec/delayed/plugins/instrumentation_spec.rb