Sha256: a4ef91d46439666cfb98d8cd4a8b61819d02f23be4ddd3d0f51d0b3938dc00d9
Contents?: true
Size: 1.27 KB
Versions: 5
Compression:
Stored size: 1.27 KB
Contents
require 'rspec' require_relative 'spec_helper' require_relative 'kv' RSpec.describe 'KeyValue' do before(:each) do @kv = Streamdal::KeyValue.new end it 'stores and retrieves key-value pair' do @kv.set('key', 'value') expect(@kv.get('key')).to eq('value') end it 'deletes a key' do expect(@kv.keys.length).to eq(0) @kv.set('key1', 'value') @kv.set('key2', 'value') expect(@kv.keys.length).to eq(2) @kv.delete('key1') expect(@kv.keys.length).to eq(1) end it 'returns array of keys' do expect(@kv.keys.length).to eq(0) @kv.set('key1', 'value') expect(@kv.keys.length).to eq(1) expect(@kv.keys[0]).to eq('key1') end it 'returns array of item values' do expect(@kv.keys.length).to eq(0) @kv.set('key1', 'value1') expect(@kv.keys.length).to eq(1) expect(@kv.items[0]).to eq('value1') end it 'returns if a key exists or not' do expect(@kv.exists('key1')).to eq(false) @kv.set('key1', 'value') expect(@kv.exists('key1')).to eq(true) end it 'purges all keys' do expect(@kv.keys.length).to eq(0) @kv.set('key1', 'value') @kv.set('key2', 'value') expect(@kv.keys.length).to eq(2) num_keys = @kv.purge expect(@kv.keys.length).to eq(0) expect(num_keys).to eq(2) end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
streamdal-0.0.5 | lib/kv_spec.rb |
streamdal-0.0.4 | lib/kv_spec.rb |
streamdal-0.0.3 | lib/kv_spec.rb |
streamdal-0.0.2 | lib/kv_spec.rb |
streamdal-0.0.1 | lib/kv_spec.rb |