Sha256: c80dc0abee05c2a4bc2ff51aa34af99053172f5fc3731af4d40bd8d64e8c973f

Contents?: true

Size: 935 Bytes

Versions: 39

Compression:

Stored size: 935 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

39 entries across 39 versions & 2 rubygems

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