File: store_test.rb

package info (click to toggle)
ruby-redis-store 1.1.6-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 284 kB
  • sloc: ruby: 909; makefile: 4
file content (46 lines) | stat: -rw-r--r-- 978 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'test_helper'

describe Redis::Store do
  def setup
    @store  = Redis::Store.new
    @client = @store.instance_variable_get(:@client)
  end

  def teardown
    @store.flushdb
    @store.quit
  end

  it "returns useful informations about the server" do
    @store.to_s.must_equal("Redis Client connected to #{@client.host}:#{@client.port} against DB #{@client.db}")
  end

  it "must force reconnection" do
    @client.expects(:reconnect)
    @store.reconnect
  end

  describe '#set' do
    describe 'with expiry' do
      let(:options) { { :expire_after => 3600 } }

      it 'must not double marshall' do
        Marshal.expects(:dump).once

        @store.set('key', 'value', options)
      end
    end
  end

  describe '#setnx' do
    describe 'with expiry' do
      let(:options) { { :expire_after => 3600 } }

      it 'must not double marshall' do
        Marshal.expects(:dump).once

        @store.setnx('key', 'value', options)
      end
    end
  end
end