Sha256: 9d72fdfc7cc7d205ef9893f574917f85884393d2a52d2cb2fed302332d6414ac

Contents?: true

Size: 804 Bytes

Versions: 32

Compression:

Stored size: 804 Bytes

Contents

require 'spec_helper'

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

  it 'returns the value after the decrement' do
    @redises.set(@key, 2)
    @redises.decr(@key).should == 1
  end

  it 'treats a missing key like 0' do
    @redises.decr(@key).should == -1
  end

  it 'decrements negative numbers' do
    @redises.set(@key, -10)
    @redises.decr(@key).should == -11
  end

  it 'works multiple times' do
    @redises.decr(@key).should == -1
    @redises.decr(@key).should == -2
    @redises.decr(@key).should == -3
  end

  it 'raises an error if the value does not look like an integer' do
    @redises.set(@key, 'minus one')
    lambda do
      @redises.decr(@key)
    end.should raise_error(Redis::CommandError)
  end

  it_should_behave_like 'a string-only command'
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
mock_redis-0.36.0 spec/commands/decr_spec.rb
mock_redis-0.35.0 spec/commands/decr_spec.rb
mock_redis-0.34.0 spec/commands/decr_spec.rb
mock_redis-0.33.0 spec/commands/decr_spec.rb
mock_redis-0.32.0 spec/commands/decr_spec.rb
mock_redis-0.31.0 spec/commands/decr_spec.rb
mock_redis-0.30.0 spec/commands/decr_spec.rb
mock_redis-0.29.0 spec/commands/decr_spec.rb
mock_redis-0.28.0 spec/commands/decr_spec.rb
mock_redis-0.27.3 spec/commands/decr_spec.rb
mock_redis-0.27.2 spec/commands/decr_spec.rb
mock_redis-0.27.1 spec/commands/decr_spec.rb
mock_redis-0.27.0 spec/commands/decr_spec.rb
mock_redis-0.26.0 spec/commands/decr_spec.rb
mock_redis-0.25.0 spec/commands/decr_spec.rb
mock_redis-0.24.0 spec/commands/decr_spec.rb
mock_redis-0.23.0 spec/commands/decr_spec.rb
mock_redis-0.22.0 spec/commands/decr_spec.rb
mock_redis-0.21.0 spec/commands/decr_spec.rb
mock_redis-0.20.0 spec/commands/decr_spec.rb