Sha256: 5c052e8126b49a4e61189eddf42ee3351ccc475a6d273035dd73ed78782ced98

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe Sidekiq::Status::Worker do

  let!(:job_id) { SecureRandom.hex(12) }

  describe ".perform_async" do
    it "generates and returns job id" do
      allow(SecureRandom).to receive(:hex).once.and_return(job_id)
      expect(StubJob.perform_async()).to eq(job_id)
    end
  end

  describe ".expiration" do
    subject { StubJob.new }

    it "allows to set/get expiration" do
      expect(subject.expiration).to be_nil
      subject.expiration = :val
      expect(subject.expiration).to eq(:val)
    end
  end

  describe ".at" do
    subject { StubJob.new }

    it "records when the worker has started" do
      expect { subject.at(0) }.to(change { subject.retrieve('working_at') })
    end

    context "when setting the total for the worker" do
      it "records when the worker has started" do
        expect { subject.total(100) }.to(change { subject.retrieve('working_at') })
      end
    end

    it "records when the worker last worked" do
      expect { subject.at(0) }.to(change { subject.retrieve('update_time') })
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sidekiq-status-3.0.3 spec/lib/sidekiq-status/worker_spec.rb
sidekiq-status-3.0.2 spec/lib/sidekiq-status/worker_spec.rb
sidekiq-status-3.0.1 spec/lib/sidekiq-status/worker_spec.rb