Sha256: 8cbb884d19905553fe45c1a5639203da248c2c67914e98ba772cbeaa62ff16e8
Contents?: true
Size: 934 Bytes
Versions: 26
Compression:
Stored size: 934 Bytes
Contents
require 'spec_helper' describe 'Core extensions' do describe 'Adding new methods for Hash items' do describe 'defining underscore_keys' do context 'from simple plain hash' do it 'underscores each key' do { 'foo-bar' => 42, foo: 42, 'foo' => 42 }.underscore_keys.should == { 'foo_bar' => 42, foo: 42, 'foo' => 42 } end end context 'from nested hashes' do it 'underscores each key' do { 'foo-bar' => { 'bar-foo' => 42, test: { 'bar-foo' => 42 } } }.underscore_keys.should == { 'foo_bar' => { 'bar_foo' => 42, test: { 'bar_foo' => 42 } } } end end context 'from hash with arrays of hashes' do it 'underscores each key' do { 'foo-bar' => [{ 'bar-foo' => 42 }, 42, { 'bar-foo' => 42 }] }.underscore_keys.should == { 'foo_bar' => [{ 'bar_foo' => 42 }, 42, { 'bar_foo' => 42 }] } end end end end end
Version data entries
26 entries across 26 versions & 1 rubygems