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

Version Path
locomotivecms-3.3.0 spec/lib/core_ext_spec.rb
locomotivecms-3.3.0.rc3 spec/lib/core_ext_spec.rb
locomotivecms-3.3.0.rc2 spec/lib/core_ext_spec.rb
locomotivecms-3.1.2 spec/lib/core_ext_spec.rb
locomotivecms-3.2.1 spec/lib/core_ext_spec.rb
locomotivecms-3.3.0.rc1 spec/lib/core_ext_spec.rb
locomotivecms-3.2.0 spec/lib/core_ext_spec.rb
locomotivecms-3.2.0.rc2 spec/lib/core_ext_spec.rb
locomotivecms-3.2.0.rc1 spec/lib/core_ext_spec.rb
locomotivecms-3.1.1 spec/lib/core_ext_spec.rb
locomotivecms-3.1.0 spec/lib/core_ext_spec.rb
locomotivecms-3.1.0.rc3 spec/lib/core_ext_spec.rb
locomotivecms-3.1.0.rc2 spec/lib/core_ext_spec.rb
locomotivecms-3.1.0.rc1 spec/lib/core_ext_spec.rb
locomotivecms-3.0.1 spec/lib/core_ext_spec.rb
locomotivecms-3.0.0 spec/lib/core_ext_spec.rb
locomotivecms-3.0.0.rc7 spec/lib/core_ext_spec.rb
locomotivecms-3.0.0.rc6 spec/lib/core_ext_spec.rb
locomotivecms-3.0.0.rc5 spec/lib/core_ext_spec.rb
locomotivecms-3.0.0.rc4 spec/lib/core_ext_spec.rb