Sha256: 4dae344e4926dcd1534370414acd3eaa60ba16f6a9125dda476dc710767cb312
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
require 'spec_helper' RSpec.describe Counter::Cache::Redis do let(:redis) { double } let(:redis_pool) { double } before do Counter::Cache.configure do |c| c.redis_pool = redis_pool end allow(redis_pool).to receive(:with).and_yield(redis) end let(:helper) { Counter::Cache::Redis.new } describe '#decr' do it 'calls decr on redis with the key' do expect(redis).to receive(:decrby).with("hello", 1) helper.decr("hello") end it 'calls decr on redis with the key and increment value' do expect(redis).to receive(:decrby).with("hello", 2) helper.decr("hello", 2) end end describe '#incr' do it 'calls incr on redis with the key' do expect(redis).to receive(:incrby).with("hello", 1) helper.incr("hello") end it 'calls incr on redis with the key and increment value' do expect(redis).to receive(:incrby).with("hello", 2) helper.incr("hello", 2) end end describe '#del' do it 'calls del on redis with the key' do expect(redis).to receive(:del).with("hello") helper.del("hello") end end describe '#get' do it 'calls get on redis with the key and returns the value' do expect(redis).to receive(:get).with("hello").and_return(2) expect(helper.get("hello")).to eq(2) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
counter-cache-0.3.0 | spec/lib/counter/cache/redis_spec.rb |
counter-cache-0.2.0 | spec/lib/counter/cache/redis_spec.rb |
counter-cache-0.1.0 | spec/lib/counter/cache/redis_spec.rb |