Sha256: 2023d8e85788c6f6b6c4f0b783c21663e7466caf7e076cb14c8f49c0eccc0d6f
Contents?: true
Size: 976 Bytes
Versions: 8
Compression:
Stored size: 976 Bytes
Contents
# frozen_string_literal: true require 'spec_helper' describe Intercom::Lib::FlatStore do it 'raises if you try to set or merge in nested hash structures' do data = Intercom::Lib::FlatStore.new _(proc { data['thing'] = [1] }).must_raise ArgumentError _(proc { data['thing'] = { 1 => 2 } }).must_raise ArgumentError _(proc { Intercom::Lib::FlatStore.new(1 => { 2 => 3 }) }).must_raise ArgumentError end it 'raises if you try to use a non string key' do data = Intercom::Lib::FlatStore.new _(proc { data[1] = 'something' }).must_raise ArgumentError end it 'sets and merges valid entries' do data = Intercom::Lib::FlatStore.new data['a'] = 1 data[:b] = 2 _(data[:a]).must_equal 1 _(data['b']).must_equal 2 _(data[:b]).must_equal 2 data = Intercom::Lib::FlatStore.new('a' => 1, :b => 2) _(data['a']).must_equal 1 _(data[:a]).must_equal 1 _(data['b']).must_equal 2 _(data[:b]).must_equal 2 end end
Version data entries
8 entries across 8 versions & 1 rubygems