Sha256: 45e816f6573885602763a56133e51bbc378e994ce22dbe9731cfcb171d47909b

Contents?: true

Size: 1.85 KB

Versions: 9

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'

describe LiveQA::Store do

  subject(:store) { LiveQA::Store }

  describe '.store' do
    it { expect(store.store).to eq({})}
  end

  describe '.store' do
    before { store.clear! }
    it { expect(store.store).to eq({})}

    context 'with values' do
      before { store.set(:test, 'value') }
      before { store.clear! }

      it { expect(store.store).to eq({}) }
    end
  end

  describe '.load_from_hash' do
    context 'with hash' do
      before { store.load_from_hash('test' => 'value', another: 'another_value') }

      it { expect(store.store).to match(test: 'value', another: 'another_value') }
    end

    it { expect { store.load_from_hash(nil) }.to_not raise_error }
  end

  describe '.set' do
    before { store.set(:test, 'value') }

    it { expect(store.store).to eq(test: 'value') }
  end

  describe '[]=' do
    before { store[:test] = 'value' }

    it { expect(store.store).to eq(test: 'value') }
  end

  describe '.get' do
    before { store.set(:test, 'value') }

    it { expect(store.get(:test)).to eq('value') }
  end

  describe '[]' do
    before { store[:test] = 'value' }

    it { expect(store[:test]).to eq('value') }
  end

  describe '.bulk_set' do
    before { store[:test] = 'value' }
    before { store.bulk_set(new_test: 'value', another: 'another_value') }

    it { expect(store.store).to match(test: 'value', new_test: 'value', another: 'another_value') }
  end

  describe '.exist?' do
    before { store.set(:test, 'value') }

    it { expect(store.exist?(:test)).to be_truthy }
    it { expect(store.exist?(:something)).to be_falsey }
  end

  describe '.exist?' do
    before { store.set(:test, 'value') }
    before { store.delete(:test)}

    it { expect(store.exist?(:test)).to be_falsey }

    context 'value does not exist' do
      it { expect { store.delete(:something) }.to_not raise_error }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
liveqa-1.9.6 spec/lib/liveqa/store_spec.rb
liveqa-1.9.5 spec/lib/liveqa/store_spec.rb
liveqa-1.9.4 spec/lib/liveqa/store_spec.rb
liveqa-1.9.3 spec/lib/liveqa/store_spec.rb
liveqa-1.9.2 spec/lib/liveqa/store_spec.rb
liveqa-1.9.1 spec/lib/liveqa/store_spec.rb
liveqa-1.9.0 spec/lib/liveqa/store_spec.rb
liveqa-1.8.3 spec/lib/liveqa/store_spec.rb
liveqa-1.4.6 spec/lib/liveqa/store_spec.rb