Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pluralization_spec.rb « i18n « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6bfc500c8b89ad6f2d58479f3005f42623eeccd7 (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
54
# frozen_string_literal: true

require 'fast_spec_helper'
require 'rspec-parameterized'
require 'rails/version'
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