Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inconsistent interpolations check to test templates #317

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions spec/i18n_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
let(:i18n) { I18n::Tasks::BaseTask.new }
let(:missing_keys) { i18n.missing_keys }
let(:unused_keys) { i18n.unused_keys }
let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }

it 'does not have missing keys' do
expect(missing_keys).to be_empty,
Expand All @@ -29,4 +30,10 @@
'Please run `i18n-tasks normalize` to fix'
expect(non_normalized).to be_empty, error_message
end

it 'does not have inconsistent interpolations' do
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
"Please run `i18n-tasks check-consistent-interpolations' to show them"
expect(inconsistent_interpolations).to be_empty, error_message
end
end
9 changes: 8 additions & 1 deletion templates/minitest/i18n_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ def test_files_are_normalized
non_normalized = @i18n.non_normalized_paths
error_message = "The following files need to be normalized:\n" \
"#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \
'Please run `i18n-tasks normalize` to fix'
"Please run `i18n-tasks normalize' to fix"
assert_empty non_normalized, error_message
end

def test_no_inconsistent_interpolations
inconsistent_interpolations = @i18n.inconsistent_interpolations
error_message = "#{inconsistent_interpolations.leaves.count} i18n keys have inconsistent interpolations.\n" \
"Please run `i18n-tasks check-consistent-interpolations' to show them"
assert_empty inconsistent_interpolations, error_message
end
end