Sha256: c388350fbc3aa46edf4d64e4739649094a4c44622b6c21432a25fb89ceffee60

Contents?: true

Size: 1.69 KB

Versions: 4

Compression:

Stored size: 1.69 KB

Contents

require 'spec_helper'

describe Taskinator::Queues::ResqueAdapter, :resque do

  it_should_behave_like "a queue adapter", :resque, Taskinator::Queues::ResqueAdapter

  let(:adapter) { Taskinator::Queues::ResqueAdapter }
  let(:uuid) {  SecureRandom.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_queued(definition.name, uuid, args)
    end

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

      expect(worker).to have_queued(definition.name, uuid, args).in(:other)
    end

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

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

      expect(worker).to have_queued(uuid)
    end

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

      expect(worker).to have_queued(uuid).in(:other)
    end

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

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
taskinator-0.3.3 spec/taskinator/queues/resque_spec.rb
taskinator-0.3.2 spec/taskinator/queues/resque_spec.rb
taskinator-0.3.1 spec/taskinator/queues/resque_spec.rb
taskinator-0.3.0 spec/taskinator/queues/resque_spec.rb