Skip to content

Commit

Permalink
add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
alecslupu committed Dec 2, 2023
1 parent 803aebd commit aea3cae
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/i18n_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require "i18n/tasks"

describe "I18n sanity" do
let(:locales) do
ENV["ENFORCED_LOCALES"].presence || "en"
end

let(:i18n) { I18n::Tasks::BaseTask.new({ locales: locales.split(",") }) }
let(:missing_keys) { i18n.missing_keys }
let(:unused_keys) { i18n.unused_keys }
let(:non_normalized_paths) { i18n.non_normalized_paths }

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

unless ENV["SKIP_NORMALIZATION"]
it "is normalized" do
error_message = "The following files need to be normalized:\n" \
"#{non_normalized_paths.map { |path| " #{path}" }.join("\n")}\n" \
"Please run `bundle exec i18n-tasks normalize --locales #{locales}` to fix them"

expect(non_normalized_paths).to be_empty, error_message
end
end
end

0 comments on commit aea3cae

Please sign in to comment.