Sha256: 753e672997efb4d6799f99e95ca522b26a2748b3c06833fdc844c88dc82d6e83

Contents?: true

Size: 922 Bytes

Versions: 4

Compression:

Stored size: 922 Bytes

Contents

require 'spec_helper'

describe Apress::Api::EventHandlerEnqueueingJob, type: :job do
  describe '#perform' do
    let(:handler) { 'handler_job' }
    let(:event_params) { {id: 100_500} }

    it 'enqueues specified handler job' do
      expect(Resque).to receive(:enqueue).with(HandlerJob, event_params)

      described_class.perform(handler, event_params)
    end

    context 'with unknown handler job class' do
      let(:handler) { 'unknown_handler_job' }

      it do
        expect { described_class.perform(handler, event_params) }.to raise_error(NameError)
      end
    end

    context 'when handler job responds to enqueue method' do
      it 'enqueues specified handler job' do
        expect(HandlerJob).to receive(:enqueue).with(event_params)
        expect(Resque).to_not receive(:enqueue).with(HandlerJob, event_params)

        described_class.perform(handler, event_params)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apress-api-1.24.0 spec/jobs/apress/api/event_handler_equeueing_job_spec.rb
apress-api-1.23.0 spec/jobs/apress/api/event_handler_equeueing_job_spec.rb
apress-api-1.22.1 spec/jobs/apress/api/event_handler_equeueing_job_spec.rb
apress-api-1.22.0 spec/jobs/apress/api/event_handler_equeueing_job_spec.rb