Wed 19 Mar 2014 01:41:53 PM UTC, comment #2:
# HG changeset patch
# User Marco Bresciani <m.bresciani@email.it>
# Date 1395236410 -3600
# Wed Mar 19 14:40:10 2014 +0100
# Node ID 35abf413131fceb7b829f83a042c2ddc8f7910ae
# Parent a3ff9592c904c7976926a2b9c13d016f62c33979
SOLVED BUG #41059
diff -r a3ff9592c904 -r 35abf413131f lib/gravaty/locales/en.yml
--- a/lib/gravaty/locales/en.yml Sun Mar 16 23:49:58 2014 +0100
+++ b/lib/gravaty/locales/en.yml Wed Mar 19 14:40:10 2014 +0100
@@ -22,3 +22,5 @@
value: "Value %{value} is not in allowed range."
warn:
deprecated: This method has been deprecated.
+ test:
+ test: test data
diff -r a3ff9592c904 -r 35abf413131f lib/gravaty/locales/it.yml
--- a/lib/gravaty/locales/it.yml Sun Mar 16 23:49:58 2014 +0100
+++ b/lib/gravaty/locales/it.yml Wed Mar 19 14:40:10 2014 +0100
@@ -22,3 +22,5 @@
value: "Il valore %{value} non è nell'intervallo previsto."
warn:
deprecated: Questo metodo è obsoleto.
+ test:
+ test: dato di prova
diff -r a3ff9592c904 -r 35abf413131f lib/gravaty/locales/ja.yml
--- a/lib/gravaty/locales/ja.yml Sun Mar 16 23:49:58 2014 +0100
+++ b/lib/gravaty/locales/ja.yml Wed Mar 19 14:40:10 2014 +0100
@@ -1,5 +1,6 @@
# gravaty
# Copyright © 2013 æ°é¨è£
+# Copyright © 2014 æ°é¨è£, Marco Bresciani
#
# This file is part of gravaty.
#
@@ -22,3 +23,5 @@
value: "å¤ %{value} ãç¯å²å¤ã§ãã"
warn:
deprecated: ãã®ã¡ã½ããã¯ãã§ã«å»æ¢ãããæ¨å¥¨ããã¦ãã¾ããã
+ test:
+ test: 試é¨ãã¼ã¿
diff -r a3ff9592c904 -r 35abf413131f test/gravaty/locales/test_locales.rb
--- a/test/gravaty/locales/test_locales.rb Sun Mar 16 23:49:58 2014 +0100
+++ b/test/gravaty/locales/test_locales.rb Wed Mar 19 14:40:10 2014 +0100
@@ -12,25 +12,45 @@
# You should have received a copy of the GNU General Public License along with gravaty. If not, see
# <http://www.gnu.org/licenses/>.
-#require_relative '../test_helper'
-#
-#describe Gravaty::Gravaty do
-# describe 'when using I18N ' do
-#
-# before do
-# I18n.load_path = Dir[File.join(File.dirname(_FILE_), '/locales/', '*.yml')]
-# end
-#
-# it 'shall return at least one available locale' do
-# I18n.available_locales.length.wont_be <= 0
-# end
-#
-# #it 'shall return the digest content on demand' do
-# # subject.digest.must_equal Gravaty::MY_MD5
-# #end
-# #
-# #it 'shall return a valid string' do
-# # subject.to_s.wont_be_nil
-# #end
-# end
-#end
+require_relative '../../test_helper'
+
+def load_yaml_file(locale)
+ filename = File::join(File::dirname(_FILE_), '/../../../lib/gravaty/locales/', "#{locale}" + '.yml')
+ filename = File::expand_path filename
+ translation = YAML::load(File::open("#{filename}"))
+end
+
+describe Gravaty::Gravaty do
+ describe 'when using I18N ' do
+ attr_reader :locales
+
+ subject { I18n.available_locales }
+
+ before do
+ I18n.load_path = Dir[File.join(File.dirname(_FILE_), '/../../../lib/gravaty/locales/', '*.yml')]
+ @locales = subject
+ end
+
+ 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, :en].each do |locale|
+ it "shall return the translated string when 'test.test' signpost is I18n'ed for #{locale}" do
+ translation = load_yaml_file(locale)
+ I18n.locale = locale
+ 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
|