#-- # wwwjdic # Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Marco Bresciani # # 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 . #++ require_relative '../../test_helper' describe WWWJDic::WWWJDic do describe 'when using I18N' do RELATIVE_PATH = '/../../../lib/wwwjdic/locales/' before do I18n.load_path = Dir[File.join(File.dirname(__FILE__), RELATIVE_PATH, '*.yml')] end subject {I18n.available_locales} it 'shall return at least one available locale' do subject.wont_be_nil subject.wont_be_empty end it 'shall contain at least English and Italiano' do subject.must_include :en subject.must_include :it end it 'shall contain a test.test signpost for each available locale' do def load_yaml_file(locale) filename = File::join(File::dirname(__FILE__), RELATIVE_PATH, "#{locale}.yml") filename = File::expand_path filename YAML::load(File::open "#{filename}") end subject.each do |locale| I18n.locale = locale translation = load_yaml_file(locale) translation["#{locale}"]['test']['test'].wont_be_nil 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}"]['test']['test'] end end end end