Sha256: c15710ef3b030268aded4c8a961719aa9edf215e491d47061ff18ca77c5ca1a6

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'que'
require 'active_record'
::Que.mode = :sync

require 'test_workers'

describe TestWorker do
  it_behaves_like "a worker"

  it { expect(TestWorker::Job).to be < ::Que::Job }
end

describe MultiWorker do
  context "when Que is loaded" do
    it "defaults to the :que adapter" do
      expect(MultiWorker.default_adapter).to eq(:que)
    end
  end

  context "when using the :que adapter" do
    before(:each) do
      Que::Job.any_instance.stub(destroy: true)
    end

    it "forwards ::perform to #perform" do
      expect_any_instance_of(TestWorker).to receive(:perform).once.with("foo")
      TestWorker.perform("foo")
    end

    it "::perform_async performs the work using Que" do
      expect_any_instance_of(TestWorker).to receive(:perform).once
      TestWorker.perform_async("foo")
    end

    it "MultiWorker.enqueue performs the work using Que" do
      expect_any_instance_of(TestWorker).to receive(:perform).once
      MultiWorker.enqueue(TestWorker, "foo")
    end

    it "exposes the Que rake task" do
      expect(MultiWorker.adapter.rake_task.name).to eq("que:work")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
multi_worker-0.2.0 spec/adapters/que_spec.rb