Sha256: e3588cedbb6fb62d7b6f929349d76dfb00c3483f29538fc3290cc35c1fa9f0c0

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe QueueClassicMatchers do
  class TestJob < QueueClassicPlus::Base
    @queue = :low
    def self.perform
    end
  end

  describe 'have_queued' do
    it 'works with no arguments' do
      expect(TestJob).to_not have_queued
      TestJob.do
      expect(TestJob).to have_queued
    end

    it 'works wiht argument' do
      expect(TestJob).to_not have_queued(1)
      TestJob.do 1
      expect(TestJob).to have_queued(1)
      expect(TestJob).to_not have_queued(2)
    end
  end

  describe 'have_queue_size_of' do
    it 'works' do
      expect(TestJob).to have_queue_size_of(0)
      expect(TestJob).to_not have_queue_size_of(1)

      TestJob.do

      expect(TestJob).to have_queue_size_of(1)
      expect(TestJob).to_not have_queue_size_of(0)
    end
  end

  describe 'have_scheduled' do
    it 'works' do
      Timecop.freeze do
        t0 = Time.now
        TestJob.enqueue_perform_in 60 * 60, 1

        expect(TestJob).to have_scheduled(1).at(t0 + 60 * 60)
        expect(TestJob).not_to have_scheduled(1).at(t0 + 60 * 60 - 3)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
queue_classic_matchers-4.0.0.alpha1 spec/queue_classic_matchers_spec.rb
queue_classic_matchers-1.1.0 spec/queue_classic_matchers_spec.rb