Sha256: 5d2ea1b3517aa29f0d80e4fc610ac9632c89b49133592a933a893281f6bf3a14
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require 'spec_helper' RSpec.describe FakeRedis do let(:redis) { Redis.new } def populate_keys_in_redis(num) num.times do |count| redis.set("key#{count}", count) end end describe '#scan' do def result returned_keys = [] cursor = 0 loop do cursor, keys = redis.scan(cursor, match_arguments) returned_keys += keys break if cursor == '0' end returned_keys end before do populate_keys_in_redis(11) end context('when deleting') do it('preverves cursor') do cursor, keys = redis.scan('0') keys.each { |key| redis.del(key) } _, keys = redis.scan(cursor) expect(keys).to eq(%w(key10)) end end context 'with one namespace' do let(:match_arguments) { {} } it 'returns the expected array of keys' do expect(result).to match_array(redis.keys) end end context 'with multiple namespaces' do let(:namespaced_key) { 'test' } let(:match_arguments) { { match: namespaced_key } } before { redis.set(namespaced_key, 12) } it 'returns the expected array of keys' do expect(result).to match_array([namespaced_key]) end end end describe 'time' do before(:each) do allow(Time).to receive_message_chain(:now, :to_f).and_return(1397845595.5139461) end it 'is an array' do expect(redis.time).to be_an_instance_of(Array) end it 'has two elements' do expect(redis.time.count).to eql 2 end if fakeredis? it 'has the current time in seconds' do expect(redis.time.first).to eql 1397845595 end it 'has the current leftover microseconds' do expect(redis.time.last).to eql 513946 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fakeredis-0.6.0 | spec/memory_spec.rb |