Sha256: ebb9d8bdc57969be895f3cff8140298128556fd5f140b86b460d43e992b01265

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe "#zadd(key, score, member)" do
  before { @key = 'mock-redis-test:zadd' }

  it "returns true if member wasn't present in the set" do
    @redises.zadd(@key, 1, 'foo').should be_true
  end

  it "returns false if member was present in the set" do
    @redises.zadd(@key, 1, 'foo')
    @redises.zadd(@key, 1, 'foo').should be_false
  end

  it "adds member to the set" do
    @redises.zadd(@key, 1, 'foo')
    @redises.zrange(@key, 0, -1).should == ['foo']
  end

  it "treats integer members as strings" do
    member = 11
    @redises.zadd(@key, 1, member)
    @redises.zrange(@key, 0, -1).should == [member.to_s]
  end

  it "updates the score" do
    @redises.zadd(@key, 1, 'foo')
    @redises.zadd(@key, 2, 'foo')

    @redises.zscore(@key, 'foo').should == 2.0
  end

  it "supports a variable number of arguments" do
    @redises.zadd(@key, [[1, 'one'], [2, 'two']])
    @redises.zadd(@key, [[3, 'three']])
    @redises.zrange(@key, 0, -1).should == ['one', 'two', 'three']
  end

  it_should_behave_like "arg 1 is a score"
  it_should_behave_like "a zset-only command"
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mock_redis-0.10.0 spec/commands/zadd_spec.rb
mock_redis-0.9.0 spec/commands/zadd_spec.rb
mock_redis-0.8.2 spec/commands/zadd_spec.rb
mock_redis-0.8.1 spec/commands/zadd_spec.rb
mock_redis-0.8.0 spec/commands/zadd_spec.rb
mock_redis-0.7.0 spec/commands/zadd_spec.rb
mock_redis-0.6.6 spec/commands/zadd_spec.rb