buggravaty - Bugs: bug #41059, I18N locales miss specific tests

 
 

bug #41059: I18N locales miss specific tests

Submitter:  Marco Bresciani <marcobresciani>
Submitted:  Wed 01 Jan 2014 07:37:18 PM UTC
   
 
Category:  Bug Severity:  2 - Minor
Item Group:  Locale/I18N Status:  Fixed
Privacy:  Public Assigned to:  marcobresciani
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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

Marco Bresciani <marcobresciani>
Group administrator
Mon 03 Feb 2014 11:45:25 AM UTC, comment #1: 

Basics example uses the I18n data to show the error message. Similar tests should be written.

Marco Bresciani <marcobresciani>
Group administrator
Wed 01 Jan 2014 07:37:18 PM UTC, original submission:  

There are no tests for I18N locales files nor (possibly) a check for missing locales and the set to a default one.

Marco Bresciani <marcobresciani>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by marcobresciani (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-03-19 marcobresciani StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2014-03-19 marcobresciani StatusConfirmed In Progress
    2014-03-19 marcobresciani Assigned toNone marcobresciani

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code