Sha256: 8fd3db9c99b8fe43a9b26a4969b0d46d625afa85a756ea4bde6204f7b0afb6b9

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe Backend::Redis::Basic do
  
  let(:redis) { described_class.new "some_namespace" }

  describe 'load, retrieve, backup, delete' do
    it 'is nothing they do (at least on the backend)' do
      redis.should_receive(:backend).never
      
      redis.load
      redis.retrieve
      redis.backup
      redis.delete
    end
  end
  
  describe 'cache_small?' do
    context 'size 0' do
      before(:each) do
        redis.stub! :size => 0
      end
      it 'is small' do
        redis.cache_small?.should == true
      end
    end
    context 'size 1' do
      before(:each) do
        redis.stub! :size => 1
      end
      it 'is not small' do
        redis.cache_small?.should == false
      end
    end
  end
  
  describe 'cache_ok?' do
    context 'size 0' do
      before(:each) do
        redis.stub! :size => 0
      end
      it 'is not ok' do
        redis.cache_ok?.should == false
      end
    end
    context 'size 1' do
      before(:each) do
        redis.stub! :size => 1
      end
      it 'is ok' do
        redis.cache_ok?.should == true
      end
    end
  end
  
  describe "size" do
    it 'delegates to the backend' do
      backend = stub :backend
      redis.stub! :backend => backend
      
      backend.should_receive(:dbsize).once.with
      
      redis.size
    end
  end
  
  describe 'to_s' do
    it 'returns the cache path with the default file extension' do
      redis.to_s.should == 'Backend::Redis::Basic(some_namespace:*)'
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
picky-2.7.0 spec/lib/backend/redis/basic_spec.rb