Sha256: 449ad95ca444e17251006df012fa820fde8ef9d7b45dcb8d8c5bdbcae7d5499f

Contents?: true

Size: 886 Bytes

Versions: 23

Compression:

Stored size: 886 Bytes

Contents

require "spec_helper"

describe Intercom::FlatStore do
  it "raises if you try to set or merge in nested hash structures" do
    data = Intercom::FlatStore.new()
    proc { data["thing"] = [1] }.must_raise ArgumentError
    proc { data["thing"] = {1 => 2} }.must_raise ArgumentError
    proc { Intercom::FlatStore.new({1 => {2 => 3}}) }.must_raise ArgumentError
  end

  it "raises if you try to use a non string key" do
    data =Intercom::FlatStore.new()
    proc { data[1] = "something" }.must_raise ArgumentError
  end

  it "sets and merges valid entries" do
    data = Intercom::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::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

23 entries across 23 versions & 1 rubygems

Version Path
intercom-0.1.4 spec/unit/intercom/flat_store_spec.rb
intercom-0.1.2 spec/unit/intercom/flat_store_spec.rb
intercom-0.1.1 spec/unit/intercom/flat_store_spec.rb