Sha256: d3b6ff8ac72ebd8904f6ea3050613332ad8b197a79160f914027e0cb636ad5f1

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

exit if jruby?

ENV["DATABASE_URL"] ||= "postgres:///queue_classic_test"
require 'queue_classic'

module QC
  class Queue
    def enqueue(method, *args)
      klass = eval(method.split(".").first)
      message = method.split(".").last
      klass.send(message, *args)
    end
  end
end

require 'test_workers'

describe TestWorker do
  it_behaves_like "a worker"
end

describe MultiWorker do
  context "when Queue Classic is loaded" do
    it "defaults to the :queue_classic adapter" do
      MultiWorker.default_adapter.should == :queue_classic
    end
  end

  context "when using the :queue_classic adapter" do
    it "performs the work using Queue Classic" do
      expect(TestWorker).to receive(:perform).exactly(3).times.with("foo")
      TestWorker.perform_async("foo")
      MultiWorker.enqueue(TestWorker, "foo")
      TestWorker.perform("foo")
    end

    it "exposes the Queue Classic rake task" do
      MultiWorker.adapter.rake_task.name.should == "qc:work"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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