Sha256: f96e925f8b304d675182f8eb8484817d986a614aef829eeb22b7158d98db9c33

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe Picky::Backends::Redis::Basic do
  
  let(:client) { stub :client }
  let(:index) { described_class.new client, :some_namespace }

  describe 'load, retrieve, backup, delete' do
    it 'is nothing they do (at least on the backend)' do
      index.should_receive(:client).never
      
      index.load
      index.retrieve
      index.backup
      index.delete
    end
  end
  
  describe 'empty' do
    it 'returns the container that is used for indexing' do
      index.empty.should == {}
    end
  end
  
  describe 'initial' do
    it 'is correct' do
      index.initial.class.should == described_class
    end
  end
  
  describe 'cache_small?' do
    context 'size 0' do
      before(:each) do
        index.stub! :size => 0
      end
      it 'is small' do
        index.cache_small?.should == true
      end
    end
    context 'size 1' do
      before(:each) do
        index.stub! :size => 1
      end
      it 'is not small' do
        index.cache_small?.should == false
      end
    end
  end
  
  describe 'cache_ok?' do
    context 'size 0' do
      before(:each) do
        index.stub! :size => 0
      end
      it 'is not ok' do
        index.cache_ok?.should == false
      end
    end
    context 'size 1' do
      before(:each) do
        index.stub! :size => 1
      end
      it 'is ok' do
        index.cache_ok?.should == true
      end
    end
  end
  
  describe "size" do
    it 'delegates to the backend' do
      client.should_receive(:dbsize).once.with
      
      index.size
    end
  end
  
  describe 'to_s' do
    it 'returns the cache path with the default file extension' do
      index.to_s.should == 'Picky::Backends::Redis::Basic(some_namespace:*)'
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picky-3.2.0 spec/lib/backends/redis/basic_spec.rb
picky-3.1.13 spec/lib/backends/redis/basic_spec.rb
picky-3.1.12 spec/lib/backends/redis/basic_spec.rb