Sha256: 6129d0c55918da7d97b84c0d310c0263d9ad28eb4363ec1029d63ce69f2894db

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

require "spec_helper"

describe Qe::Sidekiq do
  it "sets adapter when loading file" do
    Qe.adapter = nil
    load "qe/sidekiq.rb"
    expect(Qe.adapter).to eql(Qe::Sidekiq)
  end

  context "worker" do
    it "includes Sidekiq::Worker" do
      expect(Qe::Sidekiq::Worker.included_modules).to include(Sidekiq::Worker)
    end

    it "performs job" do
      expect(Qe::Worker)
        .to receive(:perform)
        .with(:a, :b, :c)

      Qe::Sidekiq::Worker.new.perform(:a, :b, :c)
    end
  end

  context "enqueuing" do
    let(:worker) {
      double("worker", :queue => "some_queue", :name => "SomeWorker")
    }

    before do
      allow(Qe::Sidekiq::Worker).to receive :perform_async
    end

    it "sets queue name" do
      expect(Qe::Sidekiq::Worker).to  receive(:sidekiq_options)
                                          .with(:queue => "some_queue")

      Qe::Sidekiq.enqueue(worker)
    end

    it "enqueues job" do
      expect(Qe::Sidekiq::Worker).to receive(:perform_async)
                                        .with("SomeWorker", :a => 1)

      Qe::Sidekiq.enqueue(worker, :a => 1)
    end
  end

  context "scheduling" do
    let(:worker) {
      double("worker", :queue => "some_queue", :name => "SomeWorker")
    }

    before do
      allow(Qe::Sidekiq::Worker).to receive(:perform_at)
    end

    it "sets queue name" do
      expect(Qe::Sidekiq::Worker).to receive(:sidekiq_options)
                                        .with(:queue => "some_queue")

      Qe::Sidekiq.enqueue(worker)
    end

    it "schedules job" do
      date = Time.now

      expect(Qe::Sidekiq::Worker).to receive(:perform_at)
                                        .with(date, "SomeWorker", :a => 1)

      Qe::Sidekiq.schedule(worker, date, :a => 1)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qe-0.3.5 spec/qe/sidekiq_spec.rb