Sha256: 7e9fd7417813d3d55f6a8772dea6ee043f19d7d779e5cf4efa4087b7755f9d21

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'

describe Picky::Backends::Redis::FloatHash do
  
  let(:client) { stub :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 'delegates to the backend' do
      client.should_receive(:hget).once.with :some_namespace, :some_symbol
      
      backend[:some_symbol]
    end
    it 'returns whatever it gets from the backend' do
      client.should_receive(:hget).any_number_of_times.and_return '1.23'
      
      backend[:anything].should == 1.23
    end
  end
  
  describe 'to_s' do
    it 'returns the cache path with the default file extension' do
      backend.to_s.should == 'Picky::Backends::Redis::FloatHash(some_namespace:*)'
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-3.1.0 spec/lib/backends/redis/float_hash_spec.rb