Sha256: 65b075be38ee90b70736a57d58d858b3954d7dbbc42f6d8ae4d599237dac82b6
Contents?: true
Size: 1.05 KB
Versions: 18
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require "i18n/tasks" RSpec.shared_examples_for "I18n sanity" do let(:locales) do ENV["ENFORCED_LOCALES"].present? ? ENV["ENFORCED_LOCALES"].split(",") : [:en] end let(:i18n) { I18n::Tasks::BaseTask.new(locales: locales) } let(:missing_keys) { i18n.missing_keys } let(:unused_keys) { i18n.unused_keys } it "does not have missing keys" do expect(missing_keys).to be_empty, "#{missing_keys.inspect} are missing" end it "does not have unused keys" do expect(unused_keys).to be_empty, "#{unused_keys.inspect} are unused" end it "is normalized" do previous_locale_hashes = locale_hashes i18n.normalize_store! new_locale_hashes = locale_hashes expect(previous_locale_hashes).to eq(new_locale_hashes), "Please normalize your locale files with `i18n-tasks normalize`" end def locale_hashes Dir.glob("config/locales/**/*.yml").inject({}) do |results, file| md5 = Digest::MD5.file(file).hexdigest results.merge(file => md5) end end end
Version data entries
18 entries across 18 versions & 2 rubygems