Sha256: bbaa1c5df308526801af09d39da34496d7df858e85c6db8054b7d5f7dbc78ef7

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe ExvoGlobalize do

  let(:backend) { I18n.backend.globalize_store }

  it "should not change a normal hash" do
    hash = { 'hello' => "Hello", 'world' => "World" }
    backend.nest_translations(hash).should eq(hash)
  end

  it "should not change a nested hash" do
    nested_hash = { 'en' => { 'hello' => "Hello World!", 'world' => "World!" } }
    backend.nest_translations(nested_hash).should eq(nested_hash)
  end

  it "should nest a simple flatten hash" do
    hash = { "hello.world" => "Hello World!" }
    nested_hash = { 'hello' => { 'world' => "Hello World!" } }
    backend.nest_translations(hash).should eq(nested_hash)
  end

  it "should nest a complicated flatten hash with symbol key" do
    hash = {
      :en => {
        "hello.world" => "Hello World!",
        "hello.earth" => "Hello Earth!"
      }
    }

    nested_hash = {
      'en' => {
        'hello' => {
          'world' => "Hello World!",
          'earth' => "Hello Earth!"
        }
      }
    }

    backend.nest_translations(hash).should eq(nested_hash)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
exvo_globalize-0.3.1 spec/exvo_globalize/flatten_spec.rb
exvo_globalize-0.3.0 spec/exvo_globalize/flatten_spec.rb
exvo_globalize-0.2.1 spec/exvo_globalize/flatten_spec.rb