Sha256: 2f6852aeb9b16aa838e5dd9ee8c62eb8712d3889acd325205c947b82088fef6f

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

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

require 'test_workers'

describe TestWorker do
  it_behaves_like "a worker"

  it { TestWorker::Job.should be < ::Que::Job }
end

describe MultiWorker do
  context "when Que is loaded" do
    it "defaults to the :que adapter" do
      MultiWorker.default_adapter.should == :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
      MultiWorker.adapter.rake_task.name.should == "que:work"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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