Sha256: 8d87aa62297f26d653ab38a57ca9d26d01af3a27d4b3045a19359ea1d440e3e4
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' require 'sidekiq/quick_debounce' require 'sidekiq' class QuickDebouncedWorker include Sidekiq::Worker sidekiq_options quick_debounce: true def perform(_a, _b); end end describe Sidekiq::QuickDebounce do after do Sidekiq.redis(&:flushdb) end let(:set) { Sidekiq::ScheduledSet.new } it 'queues a job normally at first' do QuickDebouncedWorker.perform_in(60, 'foo', 'bar') set.size.must_equal 1, 'set.size must be 1' end it 'cancels existing job for repeat jobs within the debounce time' do jid = QuickDebouncedWorker.perform_in(60, 'foo', 'bar') QuickDebouncedWorker.perform_in(60, 'foo', 'bar') Sidekiq::QuickDebounce.cancelled?(jid: jid).must_equal true, 'first jid must be cancelled' set.size.must_equal 2, 'set.size must be 2' end it 'debounces jobs based on their arguments' do jid = QuickDebouncedWorker.perform_in(60, 'boo', 'far') QuickDebouncedWorker.perform_in(60, 'foo', 'bar') Sidekiq::QuickDebounce.cancelled?(jid: jid).must_equal false, 'first jid must not be cancelled' set.size.must_equal 2, 'set.size must be 2' end it 'creates the job immediately when given an instant job' do QuickDebouncedWorker.perform_async('foo', 'bar') set.size.must_equal 0, 'set.size must be 0' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-quick-debounce-0.0.1 | spec/sidekiq/quick_debounce_spec.rb |