Sha256: 9ef8131489e7ddfb0031bfb9b266a9d3f52467487ea3866a6c446e0b5183a46f

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 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 with argument' do
      args = [1, { foo: true }, [:baz, 'bar']]
      expect(TestJob).to_not have_queued(*args)
      TestJob.do *args
      expect(TestJob).to have_queued(*args)
      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

1 entries across 1 versions & 1 rubygems

Version Path
queue_classic_matchers-4.0.0.alpha2 spec/queue_classic_matchers_spec.rb