Sha256: b2f33b6a4df6aeb627f3c43f45a7523ffa8ac6a1546459f1d972f30a06491b21

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 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.load(File.read(test_file_path))

    translations["da"]["activerecord"]["attributes"]["test_model"]["test"].should eq "new test"
    translations["da"]["activerecord"]["attributes"]["test_model"]["other_translation"].should eq "En anden"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
awesome_translations-0.0.24 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.23 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.22 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.21 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.20 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.19 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.18 spec/models/awesome_translations/translated_value_spec.rb
awesome_translations-0.0.17 spec/models/awesome_translations/translated_value_spec.rb