Sha256: 8ccaef8fb2e7d16ec58440094e64a6cfacdc81c4df128da637f434d290a8d1d0

Contents?: true

Size: 970 Bytes

Versions: 4

Compression:

Stored size: 970 Bytes

Contents

require 'spec_helper'

describe Temple::ImmutableMap do
  it 'has read accessor' do
    hash = Temple::ImmutableMap.new({a: 1},{b: 2, a: 3})
    expect(hash[:a]).to eq(1)
    expect(hash[:b]).to eq(2)
  end

  it 'has include?' do
    hash = Temple::ImmutableMap.new({a: 1},{b: 2, a: 3})
    expect(hash).to include(:a)
    expect(hash).to include(:b)
    expect(hash).not_to include(:c)
  end

  it 'has values' do
    expect(Temple::ImmutableMap.new({a: 1},{b: 2, a: 3}).values.sort).to eq([1,2])
  end

  it 'has keys' do
    expect(Temple::ImmutableMap.new({a: 1},{b: 2, a: 3}).keys).to eq([:a,:b])
  end

  it 'has to_a' do
    expect(Temple::ImmutableMap.new({a: 1},{b: 2, a: 3}).to_a).to eq([[:a, 1], [:b, 2]])
  end
end

describe Temple::MutableMap do
  it 'has write accessor' do
    parent = {a: 1}
    hash = Temple::MutableMap.new(parent)
    expect(hash[:a]).to eq(1)
    hash[:a] = 2
    expect(hash[:a]).to eq(2)
    expect(parent[:a]).to eq(1)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
temple-0.10.2 spec/map_spec.rb
temple-0.10.1 spec/map_spec.rb
temple-0.10.0 spec/map_spec.rb
temple-0.9.1 spec/map_spec.rb