Sha256: ac859faacd40e8d84144a36df68ef21c3ef29ced2bed03a39f9539f6b0c0cdc9
Contents?: true
Size: 1.21 KB
Versions: 8
Compression:
Stored size: 1.21 KB
Contents
require 'spec_helper' describe "#ltrim(key, start, stop)" do before do @key = 'mock-redis-test:22310' %w[v0 v1 v2 v3 v4].reverse.each{|v| @redises.lpush(@key, v)} end it "returns 'OK'" do @redises.ltrim(@key, 1, 3).should == 'OK' end it "trims the list to include only the specified elements" do @redises.ltrim(@key, 1, 3) @redises.lrange(@key, 0, -1).should == %w[v1 v2 v3] end it "trims the list when start and stop are strings" do @redises.ltrim(@key, '1', '3') @redises.lrange(@key, 0, -1).should == %w[v1 v2 v3] end it "trims the list to include only the specified elements (negative indices)" do @redises.ltrim(@key, -2, -1) @redises.lrange(@key, 0, -1).should == %w[v3 v4] end it "trims the list to include only the specified elements (out of range negative indices)" do @redises.ltrim(@key, -10, -2) @redises.lrange(@key, 0, -1).should == %w[v0 v1 v2 v3] end it "does not crash on overly-large indices" do @redises.ltrim(@key, 100, 200) @redises.lrange(@key, 0, -1).should == %w[] end it "removes empty lists" do @redises.ltrim(@key, 1, 0) @redises.get(@key).should be_nil end it_should_behave_like "a list-only command" end
Version data entries
8 entries across 8 versions & 1 rubygems