Sha256: eb836b73859cfb596202e2d2ad4106188697b74eb16da9d142100bca4b982c58

Contents?: true

Size: 1.18 KB

Versions: 15

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe Internals::Index::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 a collection from a StringHash. Use Index::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
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
picky-2.5.2 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.5.1 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.5.0 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.4.3 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.4.2 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.4.1 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.4.0 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.3.0 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.2.1 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.2.0 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.1.2 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.1.1 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.1.0 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.0.0 spec/lib/internals/index/redis/string_hash_spec.rb
picky-2.0.0.pre3 spec/lib/internals/index/redis/string_hash_spec.rb