Sha256: f53e804b78c29a6f8984741077d627ba9c4ff7c6482211e2e571690d45439caa

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require "spec_helper"

describe Qe::EnqueueMatcher do
  let(:date) { Time.now }

  before { Qe.jobs.clear }

  it "enqueues job" do
    expect {
      HelloWorker.enqueue(a: 1)
    }.to enqueue(HelloWorker).with(a: 1)
  end

  it "enqueues job with options as a block" do
    expect {
      HelloWorker.enqueue(a: 1)
    }.to enqueue(HelloWorker).with { {a: 1} }
  end

  it "enqueues job without mentioning options" do
    expect {
      HelloWorker.enqueue(a: 1)
    }.to enqueue(HelloWorker)
  end

  it "doesn't enqueue job" do
    expect {
      # noop
    }.not_to enqueue(HelloWorker)
  end

  it "doesn't enqueue job with options" do
    expect {
      HelloWorker.enqueue(b: 1)
    }.not_to enqueue(HelloWorker).with(a: 1)
  end

  it "schedules job" do
    expect {
      HelloWorker.enqueue(a: 1, run_at: date)
    }.to schedule(HelloWorker).on(date).with(a: 1)
  end

  it "schedules job without mentioning options" do
    expect {
      HelloWorker.enqueue(a: 1, run_at: date)
    }.to schedule(HelloWorker).on(date)
  end

  it "requires date on scheduled job" do
    expect {
      HelloWorker.enqueue(a: 1, run_at: date)
    }.not_to schedule(HelloWorker).on(nil)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qe-0.4.0 spec/qe/matchers_spec.rb
qe-0.3.5 spec/qe/matchers_spec.rb
qe-0.3.4 spec/qe/matchers_spec.rb
qe-0.3.3 spec/qe/matchers_spec.rb