File: utils_test.rb

package info (click to toggle)
ruby-i18n 1.14.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 764 kB
  • sloc: ruby: 6,560; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 938 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'test_helper'

class I18nUtilsTest < I18n::TestCase

  test ".deep_symbolize_keys" do
    hash = { 'foo' => { 'bar' => { 'baz' => 'bar' } } }
    expected = { :foo => { :bar => { :baz => 'bar' } } }
    assert_equal expected, I18n::Utils.deep_symbolize_keys(hash)
  end

  test "#deep_symbolize_keys with numeric keys" do
    hash = { 1 => { 2 => { 3 => 'bar' } } }
    expected = { 1 => { 2 => { 3 => 'bar' } } }
    assert_equal expected, I18n::Utils.deep_symbolize_keys(hash)
  end

  test "#except" do
    hash = { :foo => 'bar',  :baz => 'bar' }
    expected = { :foo => 'bar' }
    assert_equal expected, I18n::Utils.except(hash, :baz)
  end

  test "#deep_merge!" do
    hash = { :foo => { :bar => { :baz => 'bar' } }, :baz => 'bar' }
    I18n::Utils.deep_merge!(hash, :foo => { :bar => { :baz => 'foo' } })

    expected = { :foo => { :bar => { :baz => 'foo' } }, :baz => 'bar' }
    assert_equal expected, hash
  end
end