Sha256: a4be89b16fe947b52ca7b2d334eebcb5f532d11ce57333c3eb0669b3d288fc9d

Contents?: true

Size: 1019 Bytes

Versions: 2

Compression:

Stored size: 1019 Bytes

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.write(test_file_path, YAML.dump(test_translations))
  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

2 entries across 2 versions & 1 rubygems

Version Path
awesome_translations-0.0.62 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.61 spec/models/awesome_translations/translated_value_spec.rb