Sha256: a9a7e86f99bd5cfd9741f36dab40542b8c8778d8faec4e26cb57d73a1a902443

Contents?: true

Size: 928 Bytes

Versions: 7

Compression:

Stored size: 928 Bytes

Contents

require 'spec_helper'

describe '#hset(key, field)' do
  before do
    @key = 'mock-redis-test:hset'
  end

  it 'returns 1 if the key does not exist' do
    @redises.hset(@key, 'k1', 'v1').should == 1
  end

  it 'returns 1 if the key exists but the field does not' do
    @redises.hset(@key, 'k1', 'v1')
    @redises.hset(@key, 'k2', 'v2').should == 1
  end

  it 'returns 0 if the field already exists' do
    @redises.hset(@key, 'k1', 'v1')
    @redises.hset(@key, 'k1', 'v1').should == 0
  end

  it 'creates a hash there is no such field' do
    @redises.hset(@key, 'k1', 'v1')
    @redises.hget(@key, 'k1').should == 'v1'
  end

  it 'stores values as strings' do
    @redises.hset(@key, 'num', 1)
    @redises.hget(@key, 'num').should == '1'
  end

  it 'stores fields as strings' do
    @redises.hset(@key, 1, 'one')
    @redises.hget(@key, '1').should == 'one'
  end

  it_should_behave_like 'a hash-only command'
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mock_redis-0.27.3 spec/commands/hset_spec.rb
mock_redis-0.27.2 spec/commands/hset_spec.rb
mock_redis-0.27.1 spec/commands/hset_spec.rb
mock_redis-0.27.0 spec/commands/hset_spec.rb
mock_redis-0.26.0 spec/commands/hset_spec.rb
mock_redis-0.25.0 spec/commands/hset_spec.rb
mock_redis-0.24.0 spec/commands/hset_spec.rb