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.19.0 spec/commands/decr_spec.rb
mock_redis-0.18.0 spec/commands/decr_spec.rb
mock_redis-0.17.3 spec/commands/decr_spec.rb
mock_redis-0.17.2 spec/commands/decr_spec.rb
mock_redis-0.17.1 spec/commands/decr_spec.rb
mock_redis-0.17.0 spec/commands/decr_spec.rb
mock_redis-0.16.1 spec/commands/decr_spec.rb
mock_redis-0.16.0 spec/commands/decr_spec.rb
mock_redis-0.15.4 spec/commands/decr_spec.rb
mock_redis-0.15.3 spec/commands/decr_spec.rb
mock_redis-0.15.2 spec/commands/decr_spec.rb
mock_redis-0.15.1 spec/commands/decr_spec.rb