Sha256: 5885eafe589d2160ecd4d8d3c2649f1c712b099717a294303e0c899391a8b5c6

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe BasicCache::Store do
  let(:store) do
    store = BasicCache::Store.new
    (1..5).each { |i| store[i] = i + 5 }
    store
  end

  describe '#initialize' do
    it 'creates a new store raw object' do
      expect(store.raw).to be_an_instance_of Hash
    end
  end
  describe '#clear!' do
    describe 'when given no argument' do
      it 'empties the store' do
        expect(store.clear!).to eql Hash.new
      end
    end
    describe 'when given an argument' do
      it 'removes a key from the store' do
        expect(store.size).to eql 5
        store.clear! 1
        expect(store.size).to eql 4
      end
    end
  end
  describe '#[]' do
    it 'retrieves a key' do
      expect(store[1]).to eql 6
    end
  end
  describe '#[]=' do
    it 'sets a key' do
      expect(store[6] = 10).to eql 10
    end
  end
  describe '#size' do
    it 'returns the size of the store' do
      expect(store.size).to eql 5
    end
  end
  describe '#include?' do
    it 'checks for a key in the store' do
      expect(store.include? :foo).to be_falsey
      expect(store.include? 1).to be_truthy
    end
  end
  describe '#keys' do
    it 'lists the keys in the store' do
      expect(store.keys).to eql [1, 2, 3, 4, 5]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
basiccache-1.0.0 spec/basiccache/stores/store_spec.rb
basiccache-0.2.2 spec/basiccache/stores/store_spec.rb
basiccache-0.2.1 spec/basiccache/stores/store_spec.rb
basiccache-0.2.0 spec/basiccache/stores/store_spec.rb