Sha256: 766a56cba5eb0d00f21bae69a308a5257c83b8aec93ecdf70867a180b9652457

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe "#select(db)" do
  before { @key = 'mock-redis-test:select' }

  it "returns 'OK'" do
    @redises.select(0).should == 'OK'
  end

  it "treats '0' and 0 the same" do
    @redises.select('0')
    @redises.set(@key, 'foo')
    @redises.select(0)
    @redises.get(@key).should == 'foo'
  end

  it "switches databases" do
    @redises.select(0)
    @redises.set(@key, 'foo')

    @redises.select(1)
    @redises.get(@key).should be_nil

    @redises.select(0)
    @redises.get(@key).should == 'foo'
  end

  context "[mock only]" do
    # Time dependence introduces a bit of nondeterminism here
    before do
      @now = Time.now
      Time.stub!(:now).and_return(@now)

      @mock = @redises.mock

      @mock.select(0)
      @mock.set(@key, 1)
      @mock.expire(@key, 100)

      @mock.select(1)
      @mock.set(@key, 2)
      @mock.expire(@key, 200)
    end

    it "keeps expire times per-db" do
      @mock.select(0)
      @mock.ttl(@key).should == 100

      @mock.select(1)
      @mock.ttl(@key).should == 200
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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