Sha256: 0e1afa3a1de34713037cd9605193657a44b40d6a6d4cea854989d20799791408

Contents?: true

Size: 1.47 KB

Versions: 7

Compression:

Stored size: 1.47 KB

Contents

require "translations/translation_collection"

describe Translations::TranslationCollection do
  let(:translation_de) { Translations::Translation.new({ "de" => { "save" => "Speichern" } }) }
  let(:translation_en) { Translations::Translation.new({ "en" => { "save" => "Save" } }) }
  let(:translations) { Translations::TranslationCollection.new [translation_de, translation_en], "en" }

  it "should be Enumerable" do
    enumerated_translations = []

    translations.each { |translation| enumerated_translations << translation }

    assert { enumerated_translations == [translation_de, translation_en] }
  end

  it "should have a master locale" do
    assert { translations.master == translation_en }
  end

  it "should expose all translations that are not master as slaves" do
    assert { translations.slaves == [translation_de] }
  end

  describe "#for_locale" do
    it "should return the Translation for a locale" do
      assert { translations.for_locale("de") == translation_de }
    end
  end

  describe "#remove" do
    it "should remove the given key from all translations" do
      translations.remove "save"

      assert { translation_de.has_key?("save") == false }
      assert { translation_en.has_key?("save") == false }
    end
  end

  describe "#move" do
    it "should move the key in all translations" do
      translations.move "save", "x_save"

      assert { translation_de["x_save"] == "Speichern" }
      assert { translation_en["x_save"] == "Save" }
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
translations-0.3.3 spec/translations/translation_collection_spec.rb
translations-0.3.2 spec/translations/translation_collection_spec.rb
translations-0.3.1 spec/translations/translation_collection_spec.rb
translations-0.3.0 spec/translations/translation_collection_spec.rb
translations-0.2.1 spec/translations/translation_collection_spec.rb
translations-0.2.0 spec/translations/translation_collection_spec.rb
translations-0.1.0 spec/translations/translation_collection_spec.rb