Sha256: 11e1928fe27db1f3b51f8ff0c840f75659f8ec656b437aa321cb60ed7affbae3

Contents?: true

Size: 932 Bytes

Versions: 31

Compression:

Stored size: 932 Bytes

Contents

require 'spec_helper'

describe '#getbit(key, offset)' do
  before do
    @key = 'mock-redis-test:getbit'
    @redises.set(@key, 'h') # ASCII 0x68
  end

  it 'gets the bits from the key' do
    @redises.getbit(@key, 0).should == 0
    @redises.getbit(@key, 1).should == 1
    @redises.getbit(@key, 2).should == 1
    @redises.getbit(@key, 3).should == 0
    @redises.getbit(@key, 4).should == 1
    @redises.getbit(@key, 5).should == 0
    @redises.getbit(@key, 6).should == 0
    @redises.getbit(@key, 7).should == 0
  end

  it 'returns 0 for out-of-range bits' do
    @redises.getbit(@key, 100).should == 0
  end

  it 'does not modify the stored value for out-of-range bits' do
    @redises.getbit(@key, 100)
    @redises.get(@key).should == 'h'
  end

  it 'treats nonexistent keys as empty strings' do
    @redises.getbit('mock-redis-test:not-found', 0).should == 0
  end

  it_should_behave_like 'a string-only command'
end

Version data entries

31 entries across 31 versions & 1 rubygems

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