- @r.type?('foo').should == "string"
- @r.delete 'foo'
- @r.type?('foo').should == "none"
- end
- #
- it "should be able to push to the head of a list" do
- @r.push_head "list", 'hello'
- @r.push_head "list", 42
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.pop_head('list').should == '42'
- @r.delete('list')
- end
- #
- it "should be able to push to the tail of a list" do
- @r.push_tail "list", 'hello'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 1
- @r.delete('list')
- end
- #
- it "should be able to pop the tail of a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.pop_tail('list').should == 'goodbye'
- @r.delete('list')
- end
- #
- it "should be able to pop the head of a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.pop_head('list').should == 'hello'
- @r.delete('list')
- end
- #
- it "should be able to get the length of a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.delete('list')
- end
- #
- it "should be able to get a range of values from a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.push_tail "list", '1'
- @r.push_tail "list", '2'
- @r.push_tail "list", '3'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 5
- @r.list_range('list', 2, -1).should == ['1', '2', '3']
- @r.delete('list')
- end
- #
- it "should be able to trim a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.push_tail "list", '1'
- @r.push_tail "list", '2'
- @r.push_tail "list", '3'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 5
- @r.list_trim 'list', 0, 1
- @r.list_length('list').should == 2
- @r.list_range('list', 0, -1).should == ['hello', 'goodbye']
- @r.delete('list')
- end
- #
- it "should be able to get a value by indexing into a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.list_index('list', 1).should == 'goodbye'
- @r.delete('list')
- end
- #
- it "should be able to set a value by indexing into a list" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'hello'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.list_set('list', 1, 'goodbye').should be_true
- @r.list_index('list', 1).should == 'goodbye'
- @r.delete('list')
- end
- #
- it "should be able to remove values from a list LREM" do
- @r.push_tail "list", 'hello'
- @r.push_tail "list", 'goodbye'
- @r.type?('list').should == "list"
- @r.list_length('list').should == 2
- @r.list_rm('list', 1, 'hello').should == 1
- @r.list_range('list', 0, -1).should == ['goodbye']
- @r.delete('list')
- end
- #
- it "should be able add members to a set" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.type?('set').should == "set"
- @r.set_count('set').should == 2
- @r.set_members('set').sort.should == ['key1', 'key2'].sort
- @r.delete('set')
- end
- #
- it "should be able delete members to a set" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.type?('set').should == "set"
- @r.set_count('set').should == 2
- @r.set_members('set').should == Set.new(['key1', 'key2'])
- @r.set_delete('set', 'key1')
- @r.set_count('set').should == 1
- @r.set_members('set').should == Set.new(['key2'])
- @r.delete('set')
- end
- #
- it "should be able count the members of a set" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.type?('set').should == "set"
- @r.set_count('set').should == 2
- @r.delete('set')
- end
- #
- it "should be able test for set membership" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.type?('set').should == "set"
- @r.set_count('set').should == 2
- @r.set_member?('set', 'key1').should be_true
- @r.set_member?('set', 'key2').should be_true
- @r.set_member?('set', 'notthere').should be_false
- @r.delete('set')
- end
- #
- it "should be able to do set intersection" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.set_add "set2", 'key2'
- @r.set_intersect('set', 'set2').should == Set.new(['key2'])
- @r.delete('set')
- end
- #
- it "should be able to do set intersection and store the results in a key" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.set_add "set2", 'key2'
- @r.set_inter_store('newone', 'set', 'set2').should == 'OK'
- @r.set_members('newone').should == Set.new(['key2'])
- @r.delete('set')
- @r.delete('set2')
- end
- #
- it "should be able to do set union" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.set_add "set2", 'key2'
- @r.set_add "set2", 'key3'
- @r.set_union('set', 'set2').should == Set.new(['key1','key2','key3'])
- @r.delete('set')
- @r.delete('set2')
- end
- #
- it "should be able to do set union and store the results in a key" do
- @r.set_add "set", 'key1'
- @r.set_add "set", 'key2'
- @r.set_add "set2", 'key2'
- @r.set_add "set2", 'key3'
- @r.set_union_store('newone', 'set', 'set2').should == 'OK'
- @r.set_members('newone').should == Set.new(['key1','key2','key3'])
- @r.delete('set')
- @r.delete('set2')
- end
- #
- it "should be able to do set difference" do
- @r.set_add "set", 'a'
- @r.set_add "set", 'b'
- @r.set_add "set2", 'b'
- @r.set_add "set2", 'c'
- @r.set_diff('set', 'set2').should == Set.new(['a'])
- @r.delete('set')
- @r.delete('set2')
+ @r.type('foo').should == "string"
+ @r.del 'foo'
+ @r.type('foo').should == "none"
+ end
+ #
+ it "should be able to push to the head of a list (LPUSH)" do
+ @r.lpush "list", 'hello'
+ @r.lpush "list", 42
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.lpop('list').should == '42'
+ end
+ #
+ it "should be able to push to the tail of a list (RPUSH)" do
+ @r.rpush "list", 'hello'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 1
+ end
+ #
+ it "should be able to pop the tail of a list (RPOP)" do
+ @r.rpush "list", 'hello'
+ @r.rpush"list", 'goodbye'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.rpop('list').should == 'goodbye'
+ end
+ #
+ it "should be able to pop the head of a list (LPOP)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'goodbye'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.lpop('list').should == 'hello'
+ end
+ #
+ it "should be able to get the length of a list (LLEN)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'goodbye'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ end
+ #
+ it "should be able to get a range of values from a list (LRANGE)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'goodbye'
+ @r.rpush "list", '1'
+ @r.rpush "list", '2'
+ @r.rpush "list", '3'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 5
+ @r.lrange('list', 2, -1).should == ['1', '2', '3']
+ end
+ #
+ it "should be able to trim a list (LTRIM)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'goodbye'
+ @r.rpush "list", '1'
+ @r.rpush "list", '2'
+ @r.rpush "list", '3'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 5
+ @r.ltrim 'list', 0, 1
+ @r.llen('list').should == 2
+ @r.lrange('list', 0, -1).should == ['hello', 'goodbye']
+ end
+ #
+ it "should be able to get a value by indexing into a list (LINDEX)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'goodbye'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.lindex('list', 1).should == 'goodbye'
+ end
+ #
+ it "should be able to set a value by indexing into a list (LSET)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'hello'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.lset('list', 1, 'goodbye').should == 'OK'
+ @r.lindex('list', 1).should == 'goodbye'
+ end
+ #
+ it "should be able to remove values from a list (LREM)" do
+ @r.rpush "list", 'hello'
+ @r.rpush "list", 'goodbye'
+ @r.type('list').should == "list"
+ @r.llen('list').should == 2
+ @r.lrem('list', 1, 'hello').should == 1
+ @r.lrange('list', 0, -1).should == ['goodbye']
+ end
+ #
+ it "should be able add members to a set (SADD)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.type('set').should == "set"
+ @r.scard('set').should == 2
+ @r.smembers('set').sort.should == ['key1', 'key2'].sort
+ end
+ #
+ it "should be able delete members to a set (SREM)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.type('set').should == "set"
+ @r.scard('set').should == 2
+ @r.smembers('set').sort.should == ['key1', 'key2'].sort
+ @r.srem('set', 'key1')
+ @r.scard('set').should == 1
+ @r.smembers('set').should == ['key2']
+ end
+ #
+ it "should be able count the members of a set (SCARD)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.type('set').should == "set"
+ @r.scard('set').should == 2
+ end
+ #
+ it "should be able test for set membership (SISMEMBER)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.type('set').should == "set"
+ @r.scard('set').should == 2
+ @r.sismember('set', 'key1').should be_true
+ @r.sismember('set', 'key2').should be_true
+ @r.sismember('set', 'notthere').should be_false
+ end
+ #
+ it "should be able to do set intersection (SINTER)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.sadd "set2", 'key2'
+ @r.sinter('set', 'set2').should == ['key2']
+ end
+ #
+ it "should be able to do set intersection and store the results in a key (SINTERSTORE)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.sadd "set2", 'key2'
+ @r.sinterstore('newone', 'set', 'set2').should == 1
+ @r.smembers('newone').should == ['key2']
+ end
+ #
+ it "should be able to do set union (SUNION)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.sadd "set2", 'key2'
+ @r.sadd "set2", 'key3'
+ @r.sunion('set', 'set2').sort.should == ['key1','key2','key3'].sort
+ end
+ #
+ it "should be able to do set union and store the results in a key (SUNIONSTORE)" do
+ @r.sadd "set", 'key1'
+ @r.sadd "set", 'key2'
+ @r.sadd "set2", 'key2'
+ @r.sadd "set2", 'key3'
+ @r.sunionstore('newone', 'set', 'set2').should == 3
+ @r.smembers('newone').sort.should == ['key1','key2','key3'].sort
+ end
+ #
+ it "should be able to do set difference (SDIFF)" do
+ @r.sadd "set", 'a'
+ @r.sadd "set", 'b'
+ @r.sadd "set2", 'b'
+ @r.sadd "set2", 'c'
+ @r.sdiff('set', 'set2').should == ['a']