Sha256: 4e0ff7fb9c61916315618ce4c3801a2c42d090062b3d56807bc5207fb4c0efae

Contents?: true

Size: 846 Bytes

Versions: 32

Compression:

Stored size: 846 Bytes

Contents

require 'spec_helper'

describe '#decrby(key, decrement)' do
  before { @key = 'mock-redis-test:43650' }

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

  it 'treats a missing key like 0' do
    @redises.decrby(@key, 2).should == -2
  end

  it 'decrements negative numbers' do
    @redises.set(@key, -10)
    @redises.decrby(@key, 2).should == -12
  end

  it 'works multiple times' do
    @redises.decrby(@key, 2).should == -2
    @redises.decrby(@key, 2).should == -4
    @redises.decrby(@key, 2).should == -6
  end

  it 'raises an error if the value does not look like an integer' do
    @redises.set(@key, 'one')
    lambda do
      @redises.decrby(@key, 1)
    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/decrby_spec.rb
mock_redis-0.35.0 spec/commands/decrby_spec.rb
mock_redis-0.34.0 spec/commands/decrby_spec.rb
mock_redis-0.33.0 spec/commands/decrby_spec.rb
mock_redis-0.32.0 spec/commands/decrby_spec.rb
mock_redis-0.31.0 spec/commands/decrby_spec.rb
mock_redis-0.30.0 spec/commands/decrby_spec.rb
mock_redis-0.29.0 spec/commands/decrby_spec.rb
mock_redis-0.28.0 spec/commands/decrby_spec.rb
mock_redis-0.27.3 spec/commands/decrby_spec.rb
mock_redis-0.27.2 spec/commands/decrby_spec.rb
mock_redis-0.27.1 spec/commands/decrby_spec.rb
mock_redis-0.27.0 spec/commands/decrby_spec.rb
mock_redis-0.26.0 spec/commands/decrby_spec.rb
mock_redis-0.25.0 spec/commands/decrby_spec.rb
mock_redis-0.24.0 spec/commands/decrby_spec.rb
mock_redis-0.23.0 spec/commands/decrby_spec.rb
mock_redis-0.22.0 spec/commands/decrby_spec.rb
mock_redis-0.21.0 spec/commands/decrby_spec.rb
mock_redis-0.20.0 spec/commands/decrby_spec.rb