Sha256: 7ee4c3dd4e2e0d185c15fd799cf38e93f752871f796945eb9db0ac881ce7fe2b

Contents?: true

Size: 1.06 KB

Versions: 33

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe '#persist(key)' do
  before do
    @key = 'mock-redis-test:persist'
    @redises.set(@key, 'spork')
  end

  it 'returns true for a key with a timeout' do
    @redises.expire(@key, 10_000)
    @redises.persist(@key).should == true
  end

  it 'returns false for a key with no timeout' do
    @redises.persist(@key).should == false
  end

  it 'returns false for a key that does not exist' do
    @redises.persist('mock-redis-test:nonesuch').should == false
  end

  it 'removes the timeout' do
    @redises.expire(@key, 10_000)
    @redises.persist(@key)
    @redises.persist(@key).should == false
  end

  context '[mock only]' do
    # These are mock-only since we can't actually manipulate time in
    # the real Redis.

    before(:all) do
      @mock = @redises.mock
    end

    before do
      @now = Time.now
      Time.stub(:now).and_return(@now)
    end

    it 'makes keys stay around' do
      @mock.expire(@key, 5)
      @mock.persist(@key)
      Time.stub(:now).and_return(@now + 5)
      @mock.get(@key).should_not be_nil
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

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