summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2021-03-22 23:57:32 +0000
committerSamantaz Fox <coding@samantaz.fr>2021-04-21 16:10:25 +0200
commitd5d0cb6a0c179b0ea657572a464489dd40a3544d (patch)
tree26b587f626e7e8fe6ba14616513abe13e7bac339
parentcac5f20a2806214581c1846cdb395dcf3d5f2d15 (diff)
downloadinvidious-d5d0cb6a0c179b0ea657572a464489dd40a3544d.tar.gz
invidious-d5d0cb6a0c179b0ea657572a464489dd40a3544d.tar.bz2
invidious-d5d0cb6a0c179b0ea657572a464489dd40a3544d.zip
Add spec (test case) for locale files consistency
-rw-r--r--spec/locales_spec.cr31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/locales_spec.cr b/spec/locales_spec.cr
new file mode 100644
index 00000000..0bdfc13b
--- /dev/null
+++ b/spec/locales_spec.cr
@@ -0,0 +1,31 @@
+require "spec"
+require "json"
+require "../src/invidious/helpers/i18n.cr"
+
+describe "Locales" do
+
+ describe "#consistency" do
+ locales_list = LOCALES.keys.select! { |key| key != "en-US" }
+
+ locales_list.each do |locale|
+ puts "\nChecking locale #{locale}"
+ failed = false
+
+ # Use "en-US" as the reference
+ LOCALES["en-US"].each_key do |ref_key|
+ # Catch exception in order to give a hint on what caused
+ # the failure, and test one locale completely before failing
+ begin
+ LOCALES[locale].has_key?(ref_key).should be_true
+ rescue
+ failed = true
+ puts " Missing key in locale #{locale}: '#{ref_key}'"
+ end
+ end
+
+ # Throw failed assertion exception in here
+ failed.should be_false
+ end
+ end
+
+end