Sha256: a0dcc681acc9f02b81ebb624454a5f3d56888aeb5dcd7fc218cdf357e8280dcc

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe Picky::Backend::Redis::StringHash do
  
  let(:index) { described_class.new :some_namespace }
    
  describe 'dump' do
    let(:backend) { index.backend }
    it 'dumps correctly' do
      backend.should_receive(:hset).once.ordered.with :some_namespace, :a, 1
      backend.should_receive(:hset).once.ordered.with :some_namespace, :b, 2
      backend.should_receive(:hset).once.ordered.with :some_namespace, :c, 3
      
      index.dump a: 1, b: 2, c: 3
    end
  end
  
  describe 'collection' do
    it 'raises' do
      expect { index.collection :anything }.to raise_error("Can't retrieve collection for :anything from a StringHash. Use Indexes::Redis::ListHash.")
    end
  end
  
  describe 'member' do
    before(:each) do
      @backend = stub :backend
      index.stub! :backend => @backend
    end
    it 'delegates to the backend' do
      @backend.should_receive(:hget).once.with :some_namespace, :some_symbol
      
      index.member :some_symbol
    end
    it 'returns whatever it gets from the backend' do
      @backend.should_receive(:hget).any_number_of_times.and_return :some_result
      
      index.member(:anything).should == :some_result
    end
  end
  
  describe 'to_s' do
    it 'returns the cache path with the default file extension' do
      index.to_s.should == 'Picky::Backend::Redis::StringHash(some_namespace:*)'
    end
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
picky-3.0.1 spec/lib/backend/redis/string_hash_spec.rb
picky-3.0.0 spec/lib/backend/redis/string_hash_spec.rb
picky-3.0.0.pre5 spec/lib/backend/redis/string_hash_spec.rb
picky-3.0.0.pre4 spec/lib/backend/redis/string_hash_spec.rb
picky-3.0.0.pre3 spec/lib/backend/redis/string_hash_spec.rb
picky-3.0.0.pre2 spec/lib/backend/redis/string_hash_spec.rb
picky-3.0.0.pre1 spec/lib/backend/redis/string_hash_spec.rb