Show missing translation keys when test fails (#16637)
* report key and path for missing keys * move iteration out of the string into the method * make the details common to the missing and unused lists
This commit is contained in:
parent
875b1a2823
commit
41ab94eaae
1 changed files with 8 additions and 2 deletions
|
|
@ -6,14 +6,20 @@ RSpec.describe I18n do
|
|||
let(:unused_keys) { i18n.unused_keys }
|
||||
let(:inconsistent_interpolations) { i18n.inconsistent_interpolations }
|
||||
|
||||
def details(keys)
|
||||
keys.leaves.map do |node|
|
||||
{ key: node.full_key, file: node.data[:path] }
|
||||
end
|
||||
end
|
||||
|
||||
it "does not have missing keys" do
|
||||
expect(missing_keys).to be_empty,
|
||||
"Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
|
||||
"Missing #{missing_keys.leaves.count} i18n keys\n #{details(missing_keys)}"
|
||||
end
|
||||
|
||||
xit "does not have unused keys" do
|
||||
expect(unused_keys).to be_empty,
|
||||
"#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
|
||||
"#{unused_keys.leaves.count} unused i18n keys\n #{details(unused_keys)}"
|
||||
end
|
||||
|
||||
# NOTE: [@rhymes] disabling normalization check for now as it fails on CI but
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue