Sha256: fd05cb31d6fd2f945b46d47e44c1636d7c0f6773b886361fe374511a7d36be43

Contents?: true

Size: 1.24 KB

Versions: 30

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe Picky::Backends::Redis::Float do

  let(:client) { double :client }
  let(:backend) { described_class.new client, 'some_namespace' }

  describe 'dump' do
    it 'dumps correctly' do
      client.should_receive(:del).once.ordered.with  'some_namespace'
      client.should_receive(:hset).once.ordered.with 'some_namespace', 'a', 1
      client.should_receive(:hset).once.ordered.with 'some_namespace', 'b', 2
      client.should_receive(:hset).once.ordered.with 'some_namespace', 'c', 3

      backend.dump 'a' => 1, 'b' => 2, 'c' => 3
    end
  end

  describe 'member' do
    it 'forwards to the backend' do
      client.should_receive(:hget).once.with 'some_namespace', 'some'

      backend['some']
    end
    it 'returns whatever it gets from the backend' do
      client.should_receive(:hget).at_least(1).and_return '1.23'

      backend['anything'].should == 1.23
    end
    it 'returns whatever it gets from the backend' do
      client.should_receive(:hget).at_least(1).and_return nil

      backend['anything'].should == nil
    end
  end

  describe 'to_s' do
    it 'returns the cache path with the default file extension' do
      backend.to_s.should == 'Picky::Backends::Redis::Float(some_namespace:*)'
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
picky-4.31.3 spec/lib/backends/redis/float_spec.rb
picky-4.31.2 spec/lib/backends/redis/float_spec.rb
picky-4.31.1 spec/lib/backends/redis/float_spec.rb
picky-4.31.0 spec/lib/backends/redis/float_spec.rb
picky-4.30.0 spec/lib/backends/redis/float_spec.rb
picky-4.29.0 spec/lib/backends/redis/float_spec.rb
picky-4.28.1 spec/lib/backends/redis/float_spec.rb
picky-4.27.1 spec/lib/backends/redis/float_spec.rb
picky-4.27.0 spec/lib/backends/redis/float_spec.rb
picky-4.26.2 spec/lib/backends/redis/float_spec.rb
picky-4.26.1 spec/lib/backends/redis/float_spec.rb
picky-4.26.0 spec/lib/backends/redis/float_spec.rb
picky-4.25.3 spec/lib/backends/redis/float_spec.rb
picky-4.25.2 spec/lib/backends/redis/float_spec.rb
picky-4.25.1 spec/lib/backends/redis/float_spec.rb
picky-4.25.0 spec/lib/backends/redis/float_spec.rb
picky-4.24.0 spec/lib/backends/redis/float_spec.rb
picky-4.23.2 spec/lib/backends/redis/float_spec.rb
picky-4.23.1 spec/lib/backends/redis/float_spec.rb
picky-4.23.0 spec/lib/backends/redis/float_spec.rb