Sha256: ac9072190e08df2950b1ee19d01e3deea45c834949d702c7ce1f1665fd423f6c
Contents?: true
Size: 1.26 KB
Versions: 33
Compression:
Stored size: 1.26 KB
Contents
require 'spec_helper' describe '#lindex(key, index)' do before { @key = 'mock-redis-test:69312' } it 'gets an element from the list by its index' do @redises.lpush(@key, 20) @redises.lpush(@key, 10) @redises.lindex(@key, 0).should == '10' @redises.lindex(@key, 1).should == '20' end it 'treats negative indices as coming from the right' do @redises.lpush(@key, 20) @redises.lpush(@key, 10) @redises.lindex(@key, -1).should == '20' @redises.lindex(@key, -2).should == '10' end it 'gets an element from the list by its index when index is a string' do @redises.lpush(@key, 20) @redises.lpush(@key, 10) @redises.lindex(@key, '0').should == '10' @redises.lindex(@key, '1').should == '20' @redises.lindex(@key, '-1').should == '20' @redises.lindex(@key, '-2').should == '10' end it 'returns nil if the index is too large (and positive)' do @redises.lpush(@key, 20) @redises.lindex(@key, 100).should be_nil end it 'returns nil if the index is too large (and negative)' do @redises.lpush(@key, 20) @redises.lindex(@key, -100).should be_nil end it 'returns nil for nonexistent values' do @redises.lindex(@key, 0).should be_nil end it_should_behave_like 'a list-only command' end
Version data entries
33 entries across 33 versions & 1 rubygems