File: symbolize_keys_spec.rb

package info (click to toggle)
ruby-powerpack 0.1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 492 kB
  • sloc: ruby: 819; makefile: 3
file content (17 lines) | stat: -rw-r--r-- 445 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'spec_helper'

unless Hash.method_defined? :symbolize_keys
  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
end