spec/sidekiq/throttler_spec.rb in sidekiq-throttler-0.2.0 vs spec/sidekiq/throttler_spec.rb in sidekiq-throttler-0.3.0

- old
+ new

@@ -1,17 +1,21 @@ require 'spec_helper' describe Sidekiq::Throttler do subject(:throttler) do - described_class.new + described_class.new(options) end let(:worker) do LolzWorker.new end + let(:options) do + { storage: :memory } + end + let(:message) do { args: 'Clint Eastwood' } end @@ -21,14 +25,13 @@ end describe '#call' do it 'instantiates a rate limit with the worker, args, and queue' do - rate_limit = Sidekiq::Throttler::RateLimit.new(worker, message['args'], queue) Sidekiq::Throttler::RateLimit.should_receive(:new).with( - worker, message['args'], queue - ).and_return(rate_limit) + worker, message['args'], queue, options + ).and_call_original throttler.call(worker, message, queue) {} end it 'yields in RateLimit#within_bounds' do @@ -47,6 +50,6 @@ worker.class.should_receive(:perform_in).with(1.minute, *message['args']) throttler.call(worker, message, queue) end end end -end \ No newline at end of file +end