# frozen_string_literal: true #-- # wwwjdic # rubocop:disable Style/AsciiComments # © 2014 Marco Bresciani # rubocop:enable Style/AsciiComments # # This file is part of wwwjdic. # # wwwjdic is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # wwwjdic is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with wwwjdic. If not, see . # # SPDX-FileCopyrightText: 2014 Marco Bresciani # # SPDX-License-Identifier: GPL-3.0-or-later #++ require_relative '../../test_helper' RELATIVE_PATH = './' def test_one_locale it 'shall return at least one available locale' do _(subject).wont_be_nil _(subject).wont_be_empty end end def test_en_it it 'shall contain at least English and Italiano' do _(subject).must_include :en _(subject).must_include :it end end def test_translation(locale, translation) a_string = I18n.t('test.test') _(a_string).wont_be_nil _(a_string).wont_be_empty _(a_string).wont_include 'translation missing' _(a_string).must_equal translation[locale.to_s]['test']['test'] end describe WWWJDic::WWWJDic do describe 'when using I18N' do before do I18n.load_path = Dir[File.join(File.dirname(__FILE__), RELATIVE_PATH, '*.yml')] end subject { I18n.available_locales } test_one_locale test_en_it def load_yaml_file(locale) filename = File.join(File.dirname(__FILE__), RELATIVE_PATH, "#{locale}.yml") filename = File.expand_path filename YAML.safe_load(File.open(filename.to_s)) end it 'shall contain a test.test signpost for each available locale' do subject.each do |locale| I18n.locale = locale translation = load_yaml_file(locale) _(translation[locale.to_s]['test']['test']).wont_be_nil test_translation(locale, translation) end end end end