Sha256: a3d34826028226567a49dd73c59854bef0a7719d2abfa0b36b5a8c0bdb93b958

Contents?: true

Size: 978 Bytes

Versions: 19

Compression:

Stored size: 978 Bytes

Contents

require 'spec_helper'

describe "#lpush(key, value)" do
  before { @key = 'mock-redis-test:57367' }

  it "returns the new size of the list" do
    @redises.lpush(@key, 'X').should == 1
    @redises.lpush(@key, 'X').should == 2
  end

  it "creates a new list when run against a nonexistent key" do
    @redises.lpush(@key, 'value')
    @redises.llen(@key).should == 1
  end

  it "prepends items to the list" do
    @redises.lpush(@key, "bert")
    @redises.lpush(@key, "ernie")

    @redises.lindex(@key, 0).should == "ernie"
    @redises.lindex(@key, 1).should == "bert"
  end

  it "stores values as strings" do
    @redises.lpush(@key, 1)
    @redises.lindex(@key, 0).should == "1"
  end

  it "supports a variable number of arguments" do
    @redises.lpush(@key, [1, 2, 3]).should == 3
    @redises.lindex(@key, 0).should == "3"
    @redises.lindex(@key, 1).should == "2"
    @redises.lindex(@key, 2).should == "1"
  end

  it_should_behave_like "a list-only command"
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mock_redis-0.10.0 spec/commands/lpush_spec.rb
mock_redis-0.9.0 spec/commands/lpush_spec.rb
mock_redis-0.8.2 spec/commands/lpush_spec.rb
mock_redis-0.8.1 spec/commands/lpush_spec.rb
mock_redis-0.8.0 spec/commands/lpush_spec.rb
mock_redis-0.7.0 spec/commands/lpush_spec.rb
mock_redis-0.6.6 spec/commands/lpush_spec.rb
mock_redis-0.6.5 spec/commands/lpush_spec.rb
mock_redis-0.6.4 spec/commands/lpush_spec.rb
mock_redis-0.6.3 spec/commands/lpush_spec.rb
mock_redis-0.6.2 spec/commands/lpush_spec.rb
mock_redis-0.6.1 spec/commands/lpush_spec.rb
mock_redis-0.6.0 spec/commands/lpush_spec.rb
mock_redis-0.5.5 spec/commands/lpush_spec.rb
mock_redis-0.5.4 spec/commands/lpush_spec.rb
mock_redis-0.5.3 spec/commands/lpush_spec.rb
mock_redis-0.5.2 spec/commands/lpush_spec.rb
mock_redis-0.5.1 spec/commands/lpush_spec.rb
mock_redis-0.5.0 spec/commands/lpush_spec.rb