Sha256: 6ce0073a5919c8d88f1faa3dc2166cfb2bb92a63ad0733e3254ad489fae8b55b

Contents?: true

Size: 927 Bytes

Versions: 2

Compression:

Stored size: 927 Bytes

Contents

# encoding: utf-8
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../')); $:.uniq!
require 'test_helper'

class I18nBackendHelpersTest < Test::Unit::TestCase
  def setup
    @backend = I18n::Backend::Simple.new
  end
  
  test "wind_keys" do
    hash = { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i.a" => "j"}
    expected = { "a.b.c" => "d", "a.b.e" => "f", "a.g" => "h", "i.a" => "j" }
    assert_equal expected, @backend.wind_keys(hash)
  end

  test "unwind_keys" do
    hash = { "a.b.c" => "d", :"a.b.e" => "f", :"a.g" => "h", "i" => "j" }
    expected = { "a" => { "b" => { "c" => "d", "e" => "f" }, "g" => "h" }, "i" => "j"}
    assert_equal expected, @backend.unwind_keys(hash)
  end

  test "deep_symbolize_keys" do
    result = @backend.deep_symbolize_keys('foo' => { 'bar' => { 'baz' => 'bar' } })
    expected = {:foo => {:bar => {:baz => 'bar'}}}
    assert_equal expected, result
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
i18n-0.3.5 test/backend/helpers_test.rb
i18n-0.3.4 test/backend/helpers_test.rb