Sha256: 1dff530130289854783d4b65af407fbd2a75d1f1ba87014a933035ee8398b16f

Contents?: true

Size: 1.65 KB

Versions: 12

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'
RSpec.describe SidekiqUniqueJobs do
  describe '.configure_middleware' do
    it 'configures both client and server middleware' do
      expect(described_class).to receive(:configure_server_middleware)
      expect(described_class).to receive(:configure_client_middleware)

      described_class.configure_middleware
    end
  end

  describe '.configure_server_middleware' do
    let(:server_config) { class_double(Sidekiq) }
    let(:server_middleware) { double(Sidekiq::Middleware::Chain) }
    let(:client_middleware) { double(Sidekiq::Middleware::Chain) }

    it 'adds client and server middleware when required' do
      expect(Sidekiq).to receive(:configure_server).and_yield(server_config)

      expect(server_config).to receive(:client_middleware).and_yield(client_middleware)
      expect(client_middleware).to receive(:add).with(SidekiqUniqueJobs::Client::Middleware)

      expect(server_config).to receive(:server_middleware).and_yield(server_middleware)
      expect(server_middleware).to receive(:add).with(SidekiqUniqueJobs::Server::Middleware)
      described_class.configure_server_middleware
    end
  end

  describe '.configure_client_middleware' do
    let(:client_config) { class_double(Sidekiq) }
    let(:client_middleware) { double(Sidekiq::Middleware::Chain) }

    it 'adds client middleware when required' do
      expect(Sidekiq).to receive(:configure_client).and_yield(client_config)
      expect(client_config).to receive(:client_middleware).and_yield(client_middleware)
      expect(client_middleware).to receive(:add).with(SidekiqUniqueJobs::Client::Middleware)

      described_class.configure_client_middleware
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sidekiq-unique-jobs-5.0.2 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-5.0.1 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-5.0.0 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.18 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.17 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.16 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.15 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.13 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.12 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.11 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.10 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb
sidekiq-unique-jobs-4.0.9 spec/lib/sidekiq_unique_jobs/sidekiq_unique_jobs_spec.rb