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