Sha256: c205c4529c764665572e04e034c2c7d9964b9e345f47f3279f9c8f8bd0cc923a
Contents?: true
Size: 949 Bytes
Versions: 27
Compression:
Stored size: 949 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 expect({ 'foo-bar' => 42, foo: 42, 'foo' => 42 }.underscore_keys).to eq({ 'foo_bar' => 42, foo: 42, 'foo' => 42 }) end end context 'from nested hashes' do it 'underscores each key' do expect({ 'foo-bar' => { 'bar-foo' => 42, test: { 'bar-foo' => 42 } } }.underscore_keys).to eq({ 'foo_bar' => { 'bar_foo' => 42, test: { 'bar_foo' => 42 } } }) end end context 'from hash with arrays of hashes' do it 'underscores each key' do expect({ 'foo-bar' => [{ 'bar-foo' => 42 }, 42, { 'bar-foo' => 42 }] }.underscore_keys).to eq({ 'foo_bar' => [{ 'bar_foo' => 42 }, 42, { 'bar_foo' => 42 }] }) end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems