Module: Localite::Etest
- Defined in:
- lib/localite.rb
Instance Method Summary collapse
- #test_base_lookup ⇒ Object
- #test_lookup_de ⇒ Object
- #test_lookup_en ⇒ Object
- #test_lookup_in_base ⇒ Object
- #test_lookup_no_specific_lang ⇒ Object
- #test_lookup_symbols ⇒ Object
- #test_missing_lookup_symbols ⇒ Object
-
#test_tmpl ⇒ Object
make sure .t actually runs the Template engine.
Instance Method Details
#test_base_lookup ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/localite.rb', line 90 def test_base_lookup assert !I18n.load_path.empty? assert_equal("en.t", "t".t) Localite.in("en") { assert_equal("en.t", "t".t ) } Localite.in("de") { assert_equal("de.t", "t".t ) } assert_equal("de.t", Localite.in("de") { "t".t }) end |
#test_lookup_de ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/localite.rb', line 105 def test_lookup_de Localite.in("de") do # flat translation assert_equal "de.t", "t".t Localite.scope(:outer, :inner) do assert_equal("de/outer/inner/x1", "x1".t) end # Miss "x1", and don't translate missing entries assert_equal("x1", "x1".t) end end |
#test_lookup_en ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/localite.rb', line 131 def test_lookup_en Localite.in("en") do # flat translation assert_equal "en.t", "t".t Localite.scope(:outer, :inner, :x1) do assert_equal("en/outer/inner/x1", "x1".t) end # Miss "x1", and don't translate missing entries assert_equal("x1", "x1".t) end end |
#test_lookup_in_base ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/localite.rb', line 119 def test_lookup_in_base Localite.in("en") do # lookup "base" in base translation assert_equal "en_only", "base".t end Localite.in("de") do # lookup "base" in base (i.e. en) translation assert_equal "en_only", "base".t end end |
#test_lookup_no_specific_lang ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/localite.rb', line 146 def test_lookup_no_specific_lang # flat translation assert_equal "en.t", "t".t Localite.scope(:outer, :inner, :x1) do assert_equal("en/outer/inner/x1", "x1".t) end # Miss "x1", and don't translate missing entries assert_equal("x1", "x1".t) end |
#test_lookup_symbols ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/localite.rb', line 158 def test_lookup_symbols assert :base.t? assert_equal "en_only", :base.t Localite.in("en") do assert_equal "en_only", :base.t end Localite.in("de") do assert_equal "en_only", :base.t end end |
#test_missing_lookup_symbols ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/localite.rb', line 172 def test_missing_lookup_symbols assert !:missing.t? assert_raise(Localite::Translate::Missing) { assert_equal "en_only", :missing.t } Localite.in("en") do assert_raise(Localite::Translate::Missing) { :missing.t } end Localite.in("de") do assert_raise(Localite::Translate::Missing) { :missing.t } end begin :missing.t rescue Localite::Translate::Missing assert_kind_of(String, $!.to_s) end end |
#test_tmpl ⇒ Object
make sure .t actually runs the Template engine
85 86 87 88 |
# File 'lib/localite.rb', line 85 def test_tmpl assert_equal "xyz", "xyz".t(:xyz => "abc") assert_equal "abc", "{*xyz*}".t(:xyz => "abc") end |