Sha256: e6679275d388af6e3d395d91382220dd73bb0e1a922ff5a501005a3b9d59cd7c
Contents?: true
Size: 1.63 KB
Versions: 32
Compression:
Stored size: 1.63 KB
Contents
require 'spec_helper' describe Hash do let( :with_symbols ) do { stuff: 'blah', more: { stuff: { blah: 'stuff' } } } end let( :with_strings ) do { 'stuff' => 'blah', 'more' => { 'stuff' => { 'blah' => 'stuff' } } } end describe '#my_stringify_keys' do it 'recursively converts keys to strings' do expect(with_symbols.my_stringify_keys).to eq(with_strings) end context 'when the recursive is set to false' do it 'only converts the keys at depth 1' do expect(with_symbols.my_stringify_keys( false )).to eq({ 'stuff' => 'blah', 'more' => { stuff: { blah: 'stuff' } } }) end end end describe '#my_symbolize_keys' do it 'recursively converts keys to symbols' do expect(with_strings.my_symbolize_keys).to eq(with_symbols) end context 'when the recursive is set to false' do it 'only converts the keys at depth 1' do expect(with_strings.my_symbolize_keys( false )).to eq({ stuff: 'blah', more: { 'stuff' => { 'blah' => 'stuff' } } }) end end end end
Version data entries
32 entries across 32 versions & 1 rubygems