title: Rspec How to test if a Sidekiq Job was scheduled to run at a certain time
body: <p>I have the following Worker</p>
  <pre><code>class JobBlastingWorker
    include Sidekiq::Worker
    sidekiq_options queue: 'job_blasting_worker'
  
    def perform(job_id, action=nil)
      job = Job.find(job_id)
  
      JobBlastingService.new(job).call
      sidekiq_id = JobBlastingWorker.perform_in(2.minutes, job.id, 're-blast', true)
      job.sidekiq_trackers.create(sidekiq_id: sidekiq_id, worker_type: 'blast_version_update')
    end
  end
  </code></pre>
  <p>In my rspec test, i have the following <code>job_blasting_worker_spec.erb</code></p>
  <pre><code>require 'rails_helper'
  
  describe JobBlastingWorker do
    before(:all) do
      Rails.cache.clear
    end
  
    describe 'perform' do
      context 'create' do
        it 'creates job schedule for next 2mins' do
          @job = create(:job)
          worker = JobBlastingWorker.new
          expect(JobBlastingWorker).to have_enqueued_sidekiq_job(@job.id, 're-blast').in(2.minutes)
          worker.perform(@job.id, 'create')
        end
      end
    end
  end
  </code></pre>
  <p>I expect this to work but i realize that the sidekiq job that should be scheduled for the next 2minutes never gets created. Hence, the test fails.</p>
  <p>How am i able to ensure that the sidekiq job actually creates for the next 2mins and the test runs successfully?</p>