Sha256: 6762a0b4bc1070bdf37b9bc492f51e617ec7e08f427dbeb0ba91865b2cbec8d8
Contents?: true
Size: 931 Bytes
Versions: 1
Compression:
Stored size: 931 Bytes
Contents
require 'test_helper' class CoreExtTest < Minitest::Test test 'Hash#deep_symbolize_keys walks arrays, too' do hash = { 'foo' => [{ 'bar' => 'bar', 'baz' => { 'buz' => 'buz' } }] } expected = { :foo => [{ :bar => 'bar', :baz => { :buz => 'buz' } }] } assert_equal expected, hash.deep_symbolize_keys end test 'Hash#deep_symbolize_keys! replaces with deep_symbolize' do hash = { 'foo' => { 'bar' => 'baz' } } expected = { :foo => { :bar => 'baz' } } hash.deep_symbolize_keys! assert_equal expected, hash end test 'Hash#slice returns a new hash containing the given keys' do hash = { :foo => 'foo', :bar => 'bar', :baz => 'baz' } expected = { :foo => 'foo', :bar => 'bar' } assert_equal expected, hash.slice(:foo, :bar) end test 'Hash#slice does not explode on a missing key' do hash = {} expected = {} assert_equal expected, hash.slice(:foo) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hashr-1.0.0 | test/core_ext_test.rb |