Sha256: d3b1f7b9b0c8be2053ece9c2e56c15cfb1eb2e2a13eb4e6fca46027ff0a76aab

Contents?: true

Size: 1.23 KB

Versions: 2

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_false
      expect(store.include? 1).to be_true
    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

2 entries across 2 versions & 1 rubygems

Version Path
basiccache-0.1.0 spec/stores/store_spec.rb
basiccache-0.0.29 spec/stores/store_spec.rb