Sha256: cf9bc0d92f0cf541d9be458d405d3dce24b5dfcf9ba284907b684f24100a707f

Contents?: true

Size: 563 Bytes

Versions: 28

Compression:

Stored size: 563 Bytes

Contents

# typed: false

require 'spec_helper'

describe Kuby::TrailingHash do
  it 'allows adding new entries during iteration' do
    h = { a: 'b', b: 'c' }
    th = described_class[:a, 'b', :b, 'c']
    seen_keys = []

    # regular hashes don't allow adding keys during iteration
    expect do
      h.each_with_index do |(k, _), idx|
        h[:c] = 'd' if idx == 0
      end
    end.to raise_error(RuntimeError)

    th.each_with_index do |(k, _), idx|
      th[:c] = 'd' if idx == 0
      seen_keys << k
    end

    expect(seen_keys).to eq([:a, :b, :c])
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
kuby-core-0.20.2 spec/trailing_hash_spec.rb
kuby-core-0.20.1 spec/trailing_hash_spec.rb
kuby-core-0.20.0 spec/trailing_hash_spec.rb
kuby-core-0.19.0 spec/trailing_hash_spec.rb
kuby-core-0.18.0 spec/trailing_hash_spec.rb
kuby-core-0.17.0 spec/trailing_hash_spec.rb
kuby-core-0.16.1 spec/trailing_hash_spec.rb
kuby-core-0.16.0 spec/trailing_hash_spec.rb
kuby-core-0.15.0 spec/trailing_hash_spec.rb
kuby-core-0.14.0 spec/trailing_hash_spec.rb
kuby-core-0.13.0 spec/trailing_hash_spec.rb
kuby-core-0.12.0 spec/trailing_hash_spec.rb
kuby-core-0.11.16 spec/trailing_hash_spec.rb
kuby-core-0.11.15 spec/trailing_hash_spec.rb
kuby-core-0.11.14 spec/trailing_hash_spec.rb
kuby-core-0.11.13 spec/trailing_hash_spec.rb
kuby-core-0.11.12 spec/trailing_hash_spec.rb
kuby-core-0.11.11 spec/trailing_hash_spec.rb
kuby-core-0.11.10 spec/trailing_hash_spec.rb
kuby-core-0.11.9 spec/trailing_hash_spec.rb