Sha256: ecd8c9e20282976fcbc1d2b930590a7e0aba90f04e3ecdc39fbc0df549a4df09
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' describe Sidekiq::Throttler do subject(:throttler) do described_class.new(options) end let(:worker) do LolzWorker.new end let(:options) do { storage: :memory } end let(:message) do { 'args' => 'Clint Eastwood' } end let(:queue) do 'default' end describe '#call' do it 'instantiates a rate limit with the worker, args, and queue' do Sidekiq::Throttler::RateLimit.should_receive(:new).with( worker, message['args'], queue, options ).and_call_original throttler.call(worker, message, queue) {} end it 'yields in RateLimit#within_bounds' do expect { |b| throttler.call(worker, message, queue, &b) }.to yield_with_no_args end it 'calls RateLimit#execute' do Sidekiq::Throttler::RateLimit.any_instance.should_receive(:execute) throttler.call(worker, message, queue) end context 'when rate limit is exceeded' do it 'requeues the job with a delay' do Sidekiq::Throttler::RateLimit.any_instance.should_receive(:exceeded?).and_return(true) worker.class.should_receive(:perform_in).with(1.minute, *message['args']) throttler.call(worker, message, queue) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-throttler-0.4.0 | spec/sidekiq/throttler_spec.rb |