Sha256: ff79f0993d2056bbd9cc1220b733f5daa571004fd7fbf120f0c593366b9d177d

Contents?: true

Size: 1.13 KB

Versions: 32

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe '#sunion(key [, key, ...])' do
  before do
    @evens   = 'mock-redis-test:sunion:evens'
    @primes  = 'mock-redis-test:sunion:primes'

    [2, 4, 6, 8, 10].each { |i| @redises.sadd(@evens, i) }
    [2, 3, 5, 7].each { |i| @redises.sadd(@primes, i) }
  end

  it 'returns the elements in the resulting set' do
    @redises.sunion(@evens, @primes).should == %w[2 4 6 8 10 3 5 7]
  end

  it 'treats missing keys as empty sets' do
    @redises.sunion(@primes, 'mock-redis-test:nonesuch').
      should == %w[2 3 5 7]
  end

  it 'allows Array as argument' do
    @redises.sunion([@evens, @primes]).should == %w[2 4 6 8 10 3 5 7]
  end

  it 'raises an error if given 0 sets' do
    lambda do
      @redises.sunion
    end.should raise_error(Redis::CommandError)
  end

  it 'raises an error if any argument is not a a set' do
    @redises.set('mock-redis-test:notset', 1)

    lambda do
      @redises.sunion(@numbers, 'mock-redis-test:notset')
    end.should raise_error(Redis::CommandError)

    lambda do
      @redises.sunion('mock-redis-test:notset', @numbers)
    end.should raise_error(Redis::CommandError)
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

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