File: symbolize_keys_spec.rb

package info (click to toggle)
ruby-powerpack 0.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 53
  • sloc: ruby: 727; makefile: 2
file content (15 lines) | stat: -rw-r--r-- 377 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'spec_helper'

describe 'Hash#symbolize_keys' do
  it 'turn the hash keys into symbols' do
    hash = { 'one' => 1, 'two' => 2 }

    expect(hash.symbolize_keys).to eq({ one: 1, two: 2 })
  end

  it 'leaves nonconvertible keys untouched' do
    hash = { 1 => 'one', [1, 1] => 'ones' }

    expect(hash.symbolize_keys).to eq({ 1 => 'one', [1, 1] => 'ones' })
  end
end