blob: 857562d549c08a9275e65b67b5b5afb64abc0c19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rspec-parameterized'
require 'gettext_i18n_rails'
RSpec.describe Gitlab::I18n::Pluralization, feature_category: :internationalization do
describe '.call' do
subject(:rule) { described_class.call(1) }
context 'with available locales' do
around do |example|
Gitlab::I18n.with_locale(locale, &example)
end
where(:locale) do
Gitlab::I18n.available_locales
end
with_them do
it 'supports pluralization' do
expect(rule).not_to be_nil
end
end
context 'with missing rules' do
let(:locale) { "pl_PL" }
before do
stub_const("#{described_class}::MAP", described_class::MAP.except(locale))
end
it 'raises an ArgumentError' do
expect { rule }.to raise_error(ArgumentError,
/Missing pluralization rule for locale "#{locale}"/
)
end
end
end
end
describe '.install_on' do
let(:mod) { Module.new }
before do
described_class.install_on(mod)
end
it 'adds pluralisation_rule method' do
expect(mod.pluralisation_rule).to eq(described_class)
end
end
end
|