Module: Localite::Backend::Tr::Etest
- Defined in:
- lib/localite/tr.rb
Instance Method Summary collapse
- #evaluate(s) ⇒ Object
- #test_eval_string ⇒ Object
- #test_eval_string_prereq ⇒ Object
- #test_multiline_w_spaces ⇒ Object
- #test_parse_from_io ⇒ Object
- #test_parse_key_names ⇒ Object
- #test_parse_tr ⇒ Object
- #test_parse_tr_invalid ⇒ Object
- #test_tr_file ⇒ Object
Instance Method Details
#evaluate(s) ⇒ Object
172 173 174 |
# File 'lib/localite/tr.rb', line 172 def evaluate(s) Localite::Backend::Tr.new("").send(:evaluate, s) end |
#test_eval_string ⇒ Object
187 188 189 190 191 192 193 |
# File 'lib/localite/tr.rb', line 187 def test_eval_string assert_equal "ab\nc", evaluate("'ab\nc'") assert_equal "ab\ncdef", evaluate('"ab\ncdef"') assert_equal "ab\tcd\nef", evaluate('"ab\tcd\nef"') assert_equal "abbcd", evaluate('"ab\bcd"') assert_equal "en/outer/inner/y1", evaluate("\"en/outer/inner/y1\"") end |
#test_eval_string_prereq ⇒ Object
181 182 183 184 185 |
# File 'lib/localite/tr.rb', line 181 def test_eval_string_prereq assert_equal 34, '""'[0] assert_equal 34, '""'[-1] assert_equal 39, "''"[0] end |
#test_multiline_w_spaces ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/localite/tr.rb', line 271 def test_multiline_w_spaces tr = <<-TR refresh: title: t1 info: | line1 line2 line3 line4 title: t2 TR p = Localite::Backend::Tr.new(tr) d = p.parse p.stubs(:dlog) {} assert_equal "line1\nline2\n\nline3\nline4", d["refresh.info"] assert_equal "t2", d["refresh.title"] end |
#test_parse_from_io ⇒ Object
253 254 255 256 257 |
# File 'lib/localite/tr.rb', line 253 def test_parse_from_io tr = " ml: mlober" d = Localite::Backend::Tr.parse(tr) assert_equal({"ml" => "mlober"}, d) end |
#test_parse_key_names ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/localite/tr.rb', line 259 def test_parse_key_names tr = <<TR a: aa "b.c": abc "b\\nc": anlc b.c: dot TR d = Localite::Backend::Tr.parse(tr) assert_equal({"a"=>"aa", "a.b.c"=>"dot", "a.b\nc"=>"anlc"}, d) end |
#test_parse_tr ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/localite/tr.rb', line 195 def test_parse_tr tr = <<-TR # # comment param: "{* xxx *}" base: "en_only" t: "en.t" # # another comment outer: inner: x1: "en/outer/inner/x1" inner: y1: "en/outer/inner/y1" title: "This is hypertext" title2: "This is <> hypertext" ml: | mlmlml ml: mlober outer: | A first multiline entry outer: Hey Ho! outer: | A multiline entry TR p = Localite::Backend::Tr.new(tr) p.stubs(:dlog) {} assert_equal(%w(base ml outer outer.inner.x1 outer.inner.y1 param t title title2), p.keys) data = p.parse assert_equal("en/outer/inner/x1", data["outer.inner.x1"]) assert_equal(nil, data["outer.inner"]) assert_equal("A multiline\nentry", data["outer"]) assert_equal("mlober", data["ml"]) assert_kind_of(Hash, data) end |