Sha256: 20374e889843c6775058d8f56cbf3666fc31f78ad9803f35d4f38d2d8e48b186
Contents?: true
Size: 1.61 KB
Versions: 6
Compression:
Stored size: 1.61 KB
Contents
require 'spec_helper' module Hikki module Adapters describe MemcacheAdapter, :integration do context 'when actually using Memcache' do subject(:adapter) { MemcacheAdapter.new } let(:data) { { id: id, field1: 'test', field2: 123 } } let(:expected) { { 'id' => id, 'field1' => 'test', 'field2' => 123 } } let(:id) { '1' } let(:collection) { 'collection1' } it 'can store and retreive data' do adapter.remove_all(collection) adapter.index(collection, :field1) adapter.save(collection, data) expect(adapter.find(collection, id)).to eq expected expect(adapter.find(collection, '2')).to eq Hash.new expect(adapter.all(collection)).to eq [] expect(adapter.find_by(collection, :field1, 'test')).to eq [] expect(adapter.find_by(collection, :field2, 123)).to eq [] expect(adapter.find_by(collection, :field1, 'foo')).to eq [] expect(adapter.find_by(collection, :field2, 1)).to eq [] adapter.remove(collection, id) expect(adapter.find(collection, id)).to eq Hash.new expect(adapter.all(collection)).to eq [] 10.times do |i| adapter.save(collection, { id: i, field1: "test-#{i%2}" }) end expect(adapter.all(collection, {limit: 2, offset: 6})).to eq [] expect(adapter.find_by(collection, :field1, 'test-0', {limit: 2})).to eq [] adapter.remove_all(collection) expect(adapter.find(collection, id)).to eq Hash.new expect(adapter.all(collection)).to eq [] end end end end end
Version data entries
6 entries across 6 versions & 2 rubygems