Sha256: ed69bf723a2fe86f8b6f88f0bedd7ea29763bb70b452df825339ad6b1820f65e

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

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

  it "returns true if the set did not already contain member" do
    @redises.sadd(@key, 1).should be_true
  end

  it "returns false if the set did already contain member" do
    @redises.sadd(@key, 1)
    @redises.sadd(@key, 1).should be_false
  end

  it "adds member to the set" do
    @redises.sadd(@key, 1)
    @redises.sadd(@key, 2)
    @redises.smembers(@key).should == %w[2 1]
  end

  describe 'adding multiple members at once' do

    it "returns the amount of added members" do
      @redises.sadd(@key, [1, 2, 3]).should == 3
      @redises.sadd(@key, [1, 2, 3, 4]).should == 1
    end

    it "returns 0 if the set did already contain all members" do
      @redises.sadd(@key, [1, 2, 3])
      @redises.sadd(@key, [1, 2, 3]).should == 0
    end

    it "adds the members to the set" do
      @redises.sadd(@key, [1, 2, 3])
      @redises.smembers(@key).should == %w[1 2 3]
    end

  end

  it_should_behave_like "a set-only command"
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mock_redis-0.10.0 spec/commands/sadd_spec.rb
mock_redis-0.9.0 spec/commands/sadd_spec.rb
mock_redis-0.8.2 spec/commands/sadd_spec.rb
mock_redis-0.8.1 spec/commands/sadd_spec.rb
mock_redis-0.8.0 spec/commands/sadd_spec.rb
mock_redis-0.7.0 spec/commands/sadd_spec.rb
mock_redis-0.6.6 spec/commands/sadd_spec.rb
mock_redis-0.6.5 spec/commands/sadd_spec.rb
mock_redis-0.6.4 spec/commands/sadd_spec.rb
mock_redis-0.6.3 spec/commands/sadd_spec.rb
mock_redis-0.6.2 spec/commands/sadd_spec.rb
mock_redis-0.6.1 spec/commands/sadd_spec.rb
mock_redis-0.6.0 spec/commands/sadd_spec.rb
mock_redis-0.5.5 spec/commands/sadd_spec.rb
mock_redis-0.5.4 spec/commands/sadd_spec.rb
mock_redis-0.5.3 spec/commands/sadd_spec.rb
mock_redis-0.5.2 spec/commands/sadd_spec.rb