Sha256: cce8bc7325a28bd1ecbbf725e25d4f48d20ae0e41ae66059935d84cabe175cd0

Contents?: true

Size: 1.39 KB

Versions: 35

Compression:

Stored size: 1.39 KB

Contents

require 'routemaster/jobs/client'
require 'routemaster/jobs/cache_and_sweep'

RSpec.describe Routemaster::Jobs::Client do
  let(:client) { Routemaster::Jobs::Client.new(adapter) }

  let(:perform) do
    client.enqueue('routemaster', Routemaster::Jobs::CacheAndSweep, 'https://example.com/1')
  end

  describe '#enqueue' do
    before do
      allow(Routemaster::Config).to receive(:queue_adapter).and_return(backend)
      allow(client).to receive(:enqueue).and_call_original
    end

     context 'when the backend is Resque' do
      let(:backend) { :resque }
      let(:adapter) { double('Resque', enqueue_to: nil) }

      it 'queues a Resque fetch job' do
        expect(adapter).to receive(:enqueue_to).with(
          'routemaster',
          Routemaster::Jobs::Backends::Resque::JobWrapper,
          { 'class' => 'Routemaster::Jobs::CacheAndSweep', 'args' => ['https://example.com/1'] })
        perform
      end
    end

    context 'when the backend is Sidekiq' do
      let(:backend) { :sidekiq }
      let(:adapter) { double('Sidekiq', push: nil) }

      it 'queues a Sidekiq fetch job' do
        expect(adapter).to receive(:push).with(
          'queue' => 'routemaster',
          'class' => Routemaster::Jobs::Backends::Sidekiq::JobWrapper,
          'args' => [{ 'class' => 'Routemaster::Jobs::CacheAndSweep', 'args' => ['https://example.com/1'] }])
        perform
      end
    end
  end
end



Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
routemaster-drain-3.7.1 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.7.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.8 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.7 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.6 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.5 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.4 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.3 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.2 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.1 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.6.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.5.1 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.5.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.4.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.3.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.2.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.1.0 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.0.3 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.0.2 spec/routemaster/jobs/client_spec.rb
routemaster-drain-3.0.1 spec/routemaster/jobs/client_spec.rb