Sha256: 5a21014e0b8308520d35a50594e5f48495d2720fb0dc3fabb687359110d875f9
Contents?: true
Size: 1.66 KB
Versions: 16
Compression:
Stored size: 1.66 KB
Contents
require 'spec_helper' describe '#set(key, value)' do it "responds with 'OK'" do @redises.set('mock-redis-test', 1).should == 'OK' end context 'options' do it 'raises an error for EX seconds = 0' do expect do @redises.set('mock-redis-test', 1, ex: 0) end.to raise_error(Redis::CommandError, 'ERR invalid expire time in set') end it 'raises an error for PX milliseconds = 0' do expect do @redises.set('mock-redis-test', 1, px: 0) end.to raise_error(Redis::CommandError, 'ERR invalid expire time in set') end it 'accepts NX' do key = 'mock-redis-test' @redises.del(key) @redises.set(key, 1, nx: true).should == true @redises.set(key, 1, nx: true).should == false end it 'accepts XX' do key = 'mock-redis-test' @redises.del(key) @redises.set(key, 1, xx: true).should == false @redises.set(key, 1).should == 'OK' @redises.set(key, 1, xx: true).should == true end context '[mock only]' do before(:all) do @mock = @redises.mock end before do @now = Time.now Time.stub(:now).and_return(@now) end it 'accepts EX seconds' do key = 'mock-redis-test' @mock.set(key, 1, ex: 1).should == 'OK' @mock.get(key).should_not be_nil Time.stub(:now).and_return(@now + 2) @mock.get(key).should be_nil end it 'accepts PX milliseconds' do key = 'mock-redis-test' @mock.set(key, 1, px: 1000).should == 'OK' @mock.get(key).should_not be_nil Time.stub(:now).and_return(@now + 2) @mock.get(key).should be_nil end end end end
Version data entries
16 entries across 16 versions & 1 rubygems