Sha256: bcc322d7d2609e9dbe0e83ea6d7a99f56962446fda8930f4a4fd9b00092c8ffc

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

RSpec.describe SidekiqUniqueJobs::RunLockTimeoutCalculator do
  shared_context 'generic unscheduled job' do
    subject { described_class.new('class' => 'JustAWorker') }
  end

  describe 'public api' do
    it_behaves_like 'generic unscheduled job' do
      it { is_expected.to respond_to(:seconds) }
    end
  end

  describe '.for_item' do
    it 'initializes a new calculator' do
      expect(described_class).to receive(:new).with('WAT')
      described_class.for_item('WAT')
    end
  end

  describe '#seconds' do
    context 'using default run_lock_expiration' do
      subject { described_class.new(nil) }
      before { allow(subject).to receive(:worker_class_run_lock_expiration).and_return(9) }

      its(:seconds) { is_expected.to eq(9) }
    end

    context 'using specified sidekiq option run_lock_expiration' do
      subject { described_class.new(nil) }
      before { allow(subject).to receive(:worker_class_run_lock_expiration).and_return(nil) }

      its(:seconds) { is_expected.to eq(60) }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-5.0.2 spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb
sidekiq-unique-jobs-5.0.1 spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb
sidekiq-unique-jobs-5.0.0 spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb
sidekiq-unique-jobs-4.0.18 spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb
sidekiq-unique-jobs-4.0.17 spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb
sidekiq-unique-jobs-4.0.16 spec/lib/sidekiq_unique_jobs/run_lock_timeout_calculator_spec.rb