main
 1# frozen_string_literal: true
 2
 3require 'i18n/tasks'
 4
 5RSpec.describe 'I18n' do
 6  let(:i18n) { I18n::Tasks::BaseTask.new }
 7  let(:missing_keys) { i18n.missing_keys }
 8  let(:unused_keys) { i18n.unused_keys }
 9
10  it 'does not have missing keys' do
11    expect(missing_keys).to be_empty,
12      "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
13  end
14
15  it 'does not have unused keys' do
16    expect(unused_keys).to be_empty,
17      "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
18  end
19
20  it 'files are normalized' do
21    non_normalized = i18n.non_normalized_paths
22    error_message = "The following files need to be normalized:\n" \
23      "#{non_normalized.map { |path| "  #{path}" }.join("\n")}\n" \
24      'Please run `i18n-tasks normalize` to fix'
25    expect(non_normalized).to be_empty, error_message
26  end
27end