Sha256: c954b4bbfa8c079fcb91e09ebd1645610d868725fbeae8ed4c0bd94e42c07251

Contents?: true

Size: 786 Bytes

Versions: 39

Compression:

Stored size: 786 Bytes

Contents

require 'spec_helper'

describe '#incr(key)' do
  before { @key = 'mock-redis-test:33888' }

  it "returns the value after the increment" do
    @redises.set(@key, 1)
    @redises.incr(@key).should == 2
  end

  it "treats a missing key like 0" do
    @redises.incr(@key).should == 1
  end

  it "increments negative numbers" do
    @redises.set(@key, -10)
    @redises.incr(@key).should == -9
  end

  it "works multiple times" do
    @redises.incr(@key).should == 1
    @redises.incr(@key).should == 2
    @redises.incr(@key).should == 3
  end

  it "raises an error if the value does not look like an integer" do
    @redises.set(@key, "one")
    lambda do
      @redises.incr(@key)
    end.should raise_error(RuntimeError)
  end

  it_should_behave_like "a string-only command"
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
mock_redis-0.14.1 spec/commands/incr_spec.rb
mock_redis-0.14.0 spec/commands/incr_spec.rb
mock_redis-0.13.2 spec/commands/incr_spec.rb
mock_redis-0.13.1 spec/commands/incr_spec.rb
mock_redis-0.13.0 spec/commands/incr_spec.rb
mock_redis-0.12.1 spec/commands/incr_spec.rb
mock_redis-0.12.0 spec/commands/incr_spec.rb
mock_redis-0.11.0 spec/commands/incr_spec.rb
mock_redis-0.10.0 spec/commands/incr_spec.rb
mock_redis-0.9.0 spec/commands/incr_spec.rb
mock_redis-0.8.2 spec/commands/incr_spec.rb
mock_redis-0.8.1 spec/commands/incr_spec.rb
mock_redis-0.8.0 spec/commands/incr_spec.rb
mock_redis-0.7.0 spec/commands/incr_spec.rb
mock_redis-0.6.6 spec/commands/incr_spec.rb
mock_redis-0.6.5 spec/commands/incr_spec.rb
mock_redis-0.6.4 spec/commands/incr_spec.rb
mock_redis-0.6.3 spec/commands/incr_spec.rb
mock_redis-0.6.2 spec/commands/incr_spec.rb
mock_redis-0.6.1 spec/commands/incr_spec.rb