BigW Consortium Gitlab

chat_name_token_spec.rb 704 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
require 'spec_helper'

describe Gitlab::ChatNameToken, lib: true do
  context 'when using unknown token' do
    let(:token) { }

    subject { described_class.new(token).get }

    it 'returns empty data' do
      is_expected.to be_nil
    end
  end

  context 'when storing data' do
15
    let(:data) { { key: 'value' } }
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

    subject { described_class.new(@token) }

    before do
      @token = described_class.new.store!(data)
    end

    it 'returns stored data' do
      expect(subject.get).to eq(data)
    end

    context 'and after deleting them' do
      before do
        subject.delete
      end

      it 'data are removed' do
        expect(subject.get).to be_nil
      end
    end
  end
end