Skip to content

Commit 61147cf

Browse files
committed
Add a spec to test locale code formats are consistent
1 parent 63f085f commit 61147cf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/locales_spec.rb

+10
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@
8080
end
8181
end
8282

83+
it 'has only valid codes for known locales' do
84+
described_class.all.each do |locale|
85+
expect(locale.glotpress || 'xx').to match(/^[a-z]{2,3}(-[a-z]{2})?$/)
86+
expect(locale.android || 'xx-rYY').to match(/^[a-z]{2,3}(-r[A-Z]{2})?$/)
87+
expect(locale.google_play || 'xx-YY').to match(/^[a-z]{2,3}(-[A-Z]{2})?$/)
88+
expect(locale.app_store || 'xx-Yy').to match(/^[a-z]{2,3}(-[A-Za-z]{2,4})?$/)
89+
expect(locale.ios || 'xx-Yy').to match(/^[a-z]{2,3}(-[A-Za-z]{2,4})?$/)
90+
end
91+
end
92+
8393
it 'returns exactly 16 Mag16 locales' do
8494
expect(described_class.mag16.count).to eq(16)
8595
end

0 commit comments

Comments
 (0)