Sha256: 827bfd54444f5db593faab3ac7d7fbb49296cdf94b4152cac07a3c0d85e62248

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

require "spec_helper"

describe AwesomeTranslations::TranslatedValue do
  let(:test_file_path) { "#{Dir.tmpdir}/da.yml" }

  let(:translated_value) do
    described_class.new(
      file: test_file_path,
      key: "activerecord.attributes.test_model.test",
      locale: :da,
      value: "test"
    )
  end

  before do
    test_translations = {
      "da" => {
        "activerecord" => {
          "attributes" => {
            "test_model" => {
              "test" => "test",
              "other_translation" => "En anden"
            }
          }
        }
      }
    }

    File.open(test_file_path, "w") do |fp|
      fp.write(YAML.dump(test_translations))
    end
  end

  it "#save!" do
    translated_value.value = "new test"
    translated_value.save!

    translations = YAML.safe_load(File.read(test_file_path))

    expect(translations["da"]["activerecord"]["attributes"]["test_model"]["test"]).to eq "new test"
    expect(translations["da"]["activerecord"]["attributes"]["test_model"]["other_translation"]).to eq "En anden"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
awesome_translations-0.0.60 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.59 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.58 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.57 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.56 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.55 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.54 spec/models/awesome_translations/translated_value_spec.rb