Sha256: 87dde25225d8a9ccc6178dda726acbb07eb155b2cc2ed1cd1a2a5b169a47344e

Contents?: true

Size: 1.06 KB

Versions: 37

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe '#smove(source, destination, member)' do
  before do
    @src  = 'mock-redis-test:smove-source'
    @dest = 'mock-redis-test:smove-destination'

    @redises.sadd(@src, 1)
    @redises.sadd(@dest, 2)
  end

  it "returns true if the member exists in src" do
    @redises.smove(@src, @dest, 1).should be_true
  end

  it "returns false if the member exists in src" do
    @redises.smove(@src, @dest, 'nope').should be_false
  end

  it "returns true if the member exists in src and dest" do
    @redises.sadd(@dest, 1)
    @redises.smove(@src, @dest, 1).should be_true
  end

  it "moves member from source to destination" do
    @redises.smove(@src, @dest, 1)
    @redises.sismember(@dest, 1).should be_true
    @redises.sismember(@src, 1).should be_false
  end

  it "cleans up empty sets" do
    @redises.smove(@src, @dest, 1)
    @redises.get(@src).should be_nil
  end

  it "treats a nonexistent value as an empty set" do
    @redises.smove('mock-redis-test:nonesuch', @dest, 1).should be_false
  end

  it_should_behave_like "a set-only command"
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
mock_redis-0.5.4 spec/commands/smove_spec.rb
mock_redis-0.5.3 spec/commands/smove_spec.rb
mock_redis-0.5.2 spec/commands/smove_spec.rb
mock_redis-0.5.1 spec/commands/smove_spec.rb
mock_redis-0.5.0 spec/commands/smove_spec.rb
mock_redis-0.4.1 spec/commands/smove_spec.rb
mock_redis-0.4.0 spec/commands/smove_spec.rb
mock_redis-0.3.0 spec/commands/smove_spec.rb
ryansch-mock_redis-0.3.0 spec/commands/smove_spec.rb
ryansch-mock_redis-0.2.0.2 spec/commands/smove_spec.rb
ryansch-mock_redis-0.2.0.1 spec/commands/smove_spec.rb
mock_redis-0.2.0 spec/commands/smove_spec.rb
mock_redis-0.1.2 spec/commands/smove_spec.rb
mock_redis-0.1.1 spec/commands/smove_spec.rb
mock_redis-0.1.0 spec/commands/smove_spec.rb
mock_redis-0.0.2 spec/commands/smove_spec.rb
mock_redis-0.0.1 spec/commands/smove_spec.rb