Sha256: d4cdaf39cada995d49a534e9ef174b7996da39f16e446e8f4e672c09507b30d7
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
# encoding: utf-8 require 'spec_helper' require 'fedux_org_stdlib/shell_language_detector' RSpec.describe ShellLanguageDetector do context '#detect' do it 'returns language' do environment = instance_double('FeduxOrgStdlib::ProcessEnvironment') allow(environment).to receive(:fetch).and_return 'de_DE.UTF-8' detector = ShellLanguageDetector.new environment: environment language = detector.detect expect(language.language_code).to eq :de expect(language.country_code).to eq :de end it 'returns language if is allowed' do environment = instance_double('FeduxOrgStdlib::ProcessEnvironment') allow(environment).to receive(:fetch).and_return 'en_GB.UTF-8' detector = ShellLanguageDetector.new environment: environment, default_country_code: :de, default_language_code: :de language = detector.detect allowed: :en expect(language.language_code).to eq :en expect(language.country_code).to eq :gb end it 'returns default language if is not allowed' do environment = instance_double('FeduxOrgStdlib::ProcessEnvironment') allow(environment).to receive(:fetch).and_return 'en_GB.UTF-8' detector = ShellLanguageDetector.new environment: environment, default_country_code: :de, default_language_code: :de language = detector.detect allowed: :de expect(language.language_code).to eq :de expect(language.country_code).to eq :de end it 'returns default language if is not allowed for multiple languages' do environment = instance_double('FeduxOrgStdlib::ProcessEnvironment') allow(environment).to receive(:fetch).and_return 'en_GB.UTF-8' detector = ShellLanguageDetector.new environment: environment, default_country_code: :de, default_language_code: :de language = detector.detect allowed: [:de, :nl] expect(language.language_code).to eq :de expect(language.country_code).to eq :de end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fedux_org-stdlib-0.6.31 | spec/shell_language_detector_spec.rb |
fedux_org-stdlib-0.6.30 | spec/shell_language_detector_spec.rb |