Sha256: ac2e7f2f32e2735363a25b66b9893346ea5001252c5a32ba7f938567f0d48000

Contents?: true

Size: 902 Bytes

Versions: 2

Compression:

Stored size: 902 Bytes

Contents

# encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')

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

  def test_unwind_keys
    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

  def test_deep_symbolize_keys
    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 & 2 rubygems

Version Path
activesupport-2.3.6.pre lib/active_support/vendor/i18n-0.3.3/test/cases/backend/helpers_test.rb
i18n-0.3.3 test/cases/backend/helpers_test.rb