spec/spec_helper.rb in cldr-plurals-1.1.0 vs spec/spec_helper.rb in cldr-plurals-1.1.1
- old
+ new
@@ -6,10 +6,14 @@
RSpec.configure do |config|
config.mock_with :rr
end
+ADDITIONAL_SAMPLES = {
+ "ar" => { other: %w(3.1 3.2 3.3) } # improve test coverage for Arabic
+}
+
def each_rule
samples.each_pair do |locales, rules|
rules.each do |rule|
next if rule[:text].empty? # skip other rule test, as it's a fallback
tokens = CldrPlurals::Compiler::Tokenizer.tokenize(rule[:text])
@@ -17,10 +21,11 @@
yield locales, rule_ast, rule[:samples]
end
end
end
+
def each_rule_list
samples.each_pair do |locales, rules|
rule_list = CldrPlurals::Compiler::RuleList.new(locales)
samples = {}
@@ -31,9 +36,13 @@
samples_per_name = samples.each_with_object({}) do |(name, samples), ret|
ret[name] = samples.flat_map do |sample_info|
sample_info[:samples]
end
+ end
+
+ (ADDITIONAL_SAMPLES[locales] || {}).each do |name, more_samples|
+ samples_per_name[name].concat(more_samples)
end
yield rule_list, samples_per_name
end
end