Sha256: ba4b463f6dc9ab124de98445ec488ac24e050c5b5b9c99c6222c3b93cedee274

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe Taskinator::Queues::SidekiqAdapter, :sidekiq do

  it_should_behave_like "a queue adapter", :sidekiq, Taskinator::Queues::SidekiqAdapter do
    let(:job) { double('job', :get_sidekiq_options => {}) }
  end

  let(:adapter) { Taskinator::Queues::SidekiqAdapter }
  let(:uuid) {  Taskinator.generate_uuid }

  subject { adapter.new }

  describe "CreateProcessWorker" do
    let(:args) { Taskinator::Persistence.serialize(:foo => :bar) }

    it "enqueues" do
      worker = adapter::CreateProcessWorker
      definition = MockDefinition.create
      subject.enqueue_create_process(definition, uuid, :foo => :bar)
      expect(worker).to have_enqueued_sidekiq_job(definition.name, uuid, args)
    end

    it "enqueues to specified queue" do
      subject.enqueue_create_process(MockDefinition.create(:other), uuid, :foo => :bar)
      expect(adapter::CreateProcessWorker).to be_processed_in_x(:other)
    end

    it "calls worker" do
      definition = MockDefinition.create
      expect_any_instance_of(Taskinator::CreateProcessWorker).to receive(:perform)
      adapter::CreateProcessWorker.new.perform(definition.name, uuid, args)
    end
  end

  describe "TaskWorker" do
    it "enqueues tasks" do
      worker = adapter::TaskWorker
      task = double('task', :uuid => uuid, :queue => nil)
      subject.enqueue_task(task)
      expect(worker).to have_enqueued_sidekiq_job(task.uuid)
    end

    it "enqueues task to specified queue" do
      subject.enqueue_task(double('task', :uuid => uuid, :queue => :other))
      expect(adapter::TaskWorker).to be_processed_in_x(:other)
    end

    it "calls task worker" do
      expect_any_instance_of(Taskinator::TaskWorker).to receive(:perform)
      adapter::TaskWorker.new.perform(uuid)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taskinator-0.5.2 spec/taskinator/queues/sidekiq_spec.rb
taskinator-0.5.1 spec/taskinator/queues/sidekiq_spec.rb
taskinator-0.5.0 spec/taskinator/queues/sidekiq_spec.rb