Sha256: 2169c1d7065389ad2b10708c762c1b1d38f32ba4f1b11b398ad6857a7f915bcc

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'babelyoda/localization_value'

describe "localization value" do
  it "can be created" do
    value = Babelyoda::LocalizationValue.new(:en, "Value 1")
    value.language.should == :en
    value.text.should == "Value 1"
  end
  
  it "should merge non-plural values" do
    value1 = Babelyoda::LocalizationValue.new(:en, "Value 1")
    value2 = Babelyoda::LocalizationValue.new(:en, "Value 2")
    value1.merge!(value2)
    value1.language.should == :en
    value1.text.should == "Value 2"
  end
  
  it "should preserve values if specified so in options and the status != :translation_required" do
    value1 = Babelyoda::LocalizationValue.new(:en, "Value 1")
    value1.status = :translated
    value2 = Babelyoda::LocalizationValue.new(:en, "Value 2")
    value1.merge!(value2, { preserve: true })
    value1.language.should == :en
    value1.text.should == "Value 1"
  end

  it "should preserve values in status :requires_translation if the project uses non plain text keys" do
    value1 = Babelyoda::LocalizationValue.new(:en, "Value 1")
    value2 = Babelyoda::LocalizationValue.new(:en, "Value 2")
    value1.merge!(value2, { preserve: true, plain_text_keys: false })
    value1.language.should == :en
    value1.text.should == "Value 1"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
babelyoda-2.1.9 spec/lib/babelyoda/localization_value_spec.rb
babelyoda-2.1.8 spec/lib/babelyoda/localization_value_spec.rb
babelyoda-2.1.7 spec/lib/babelyoda/localization_value_spec.rb
babelyoda-2.1.6 spec/lib/babelyoda/localization_value_spec.rb