Sha256: a6187f74a734210cbfc27808f5e30d97e81c7f7689df9cb2775bc3ce4a5184d4
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
# encoding: utf-8 describe 'Array#symbolize_keys_recursively' do it 'should convert keys to symbols' do array_old = [:abc, 'xyz', { 'foo' => 'bar', :baz => :qux }] array_new = [:abc, 'xyz', { foo: 'bar', baz: :qux }] array_old.symbolize_keys_recursively.must_equal array_new end end describe 'Array#stringify_keys_recursively' do it 'should convert keys to strings' do array_old = [:abc, 'xyz', { :foo => 'bar', 'baz' => :qux }] array_new = [:abc, 'xyz', { 'foo' => 'bar', 'baz' => :qux }] array_old.stringify_keys_recursively.must_equal array_new end end describe 'Array#freeze_recursively' do include Nanoc::TestHelpers it 'should prevent first-level elements from being modified' do array = [:a, [:b, :c], :d] array.freeze_recursively assert_raises_frozen_error do array[0] = 123 end end it 'should prevent second-level elements from being modified' do array = [:a, [:b, :c], :d] array.freeze_recursively assert_raises_frozen_error do array[1][0] = 123 end end it 'should not freeze infinitely' do a = [] a << a a.freeze_recursively assert a.frozen? assert a[0].frozen? assert_equal a, a[0] end end describe 'Array#checksum' do it 'should work' do expectation = 'CEUlNvu/3DUmlbtpFRiLHU8oHA0=' [[:foo, 123]].checksum.must_equal expectation end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc-3.8.0 | test/base/core_ext/array_spec.rb |
nanoc-3.7.5 | test/base/core_ext/array_spec.rb |