Sha256: a95956e373f5cc770cc6c302fe7024cd9aa13e5c7ad628a36c5f1c7d1ed30539
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
require "spec_helper" describe Throttle do let(:key) { :test } let(:max) { 30 } let(:polling) { 0.25 } let(:timeout) { 1 } let(:redis) { Redis.current } let(:ns) { :throttled_actions } let(:counter) { double(:counter, count: nil) } let(:opts) { {} } shared_examples "Throttle API" do it "initializes throttle with options and limits given block" do expect(described_class::RedisScript).to receive(:new). with(redis, "#{ns}:#{key}", max). and_call_original expect(described_class::Instance).to receive(:new). with(kind_of(described_class::RedisScript), polling, timeout). and_call_original expect(counter).to receive(:count) described_class.for(key, max, opts) { counter.count } end end describe "using options" do let(:opts) { {polling: polling, timeout: timeout, redis: redis, ns: ns} } it_behaves_like "Throttle API" end describe "using defaults" do before(:each) do Throttle.default_polling = polling Throttle.default_timeout = timeout Throttle.default_redis_client = redis Throttle.default_ns = ns end it_behaves_like "Throttle API" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
full_throttle-0.0.1 | spec/lib/throttle_spec.rb |