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

Version Path
locomotive_cms-2.5.7 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.6 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.6.rc2 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.6.rc1 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.5 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.4 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.3 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.2 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.1 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.0 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.0.rc3 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.0.rc2 spec/lib/core_ext_spec.rb
locomotive_cms-2.5.0.rc1 spec/lib/core_ext_spec.rb
locomotive_cms-2.4.1 spec/lib/core_ext_spec.rb
locomotive_cms-2.4.0 spec/lib/core_ext_spec.rb
locomotive_cms-2.3.1 spec/lib/core_ext_spec.rb
locomotive_cms-2.3.0 spec/lib/core_ext_spec.rb
locomotive_cms-2.2.3 spec/lib/core_ext_spec.rb
locomotive_cms-2.2.2 spec/lib/core_ext_spec.rb
locomotive_cms-2.2.1 spec/lib/core_ext_spec.rb