spec/lib/backends/redis/basic_spec.rb in picky-3.2.0 vs spec/lib/backends/redis/basic_spec.rb in picky-3.3.0

- old
+ new

@@ -1,83 +1,107 @@ require 'spec_helper' describe Picky::Backends::Redis::Basic do let(:client) { stub :client } - let(:index) { described_class.new client, :some_namespace } + + context 'without options' do + 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 + 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 - end - - describe 'empty' do - it 'returns the container that is used for indexing' do - index.empty.should == {} + + describe 'empty' do + it 'returns the container that is used for indexing' do + index.empty.should == {} + end end - end - - describe 'initial' do - it 'is correct' do - index.initial.class.should == described_class + + describe 'initial' do + it 'is correct' do + index.initial.class.should == described_class + end end - end - - describe 'cache_small?' do - context 'size 0' do - before(:each) do - index.stub! :size => 0 + + 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 - it 'is small' do - index.cache_small?.should == true + 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 - context 'size 1' do - before(:each) do - index.stub! :size => 1 + + 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 - it 'is not small' do - index.cache_small?.should == false + context 'size 1' do + before(:each) do + index.stub! :size => 1 + end + it 'is ok' do + index.cache_ok?.should == true + end end end - end - - describe 'cache_ok?' do - context 'size 0' do - before(:each) do - index.stub! :size => 0 + + describe "size" do + it 'delegates to the backend' do + client.should_receive(:dbsize).once.with + + index.size end - it 'is not ok' do - index.cache_ok?.should == false - end end - context 'size 1' do - before(:each) do - index.stub! :size => 1 + + 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 - 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 + context 'with options' do + let(:index) do + described_class.new client, + :some_namespace, + empty: [], + initial: [] 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:*)' + + 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 == Array + end end end end \ No newline at end of file