File: i18n_unit_test.rb

package info (click to toggle)
ruby-liquid 5.4.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,176 kB
  • sloc: ruby: 10,561; makefile: 6
file content (39 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# frozen_string_literal: true

require 'test_helper'

class I18nUnitTest < Minitest::Test
  include Liquid

  def setup
    @i18n = I18n.new(fixture("en_locale.yml"))
  end

  def test_simple_translate_string
    assert_equal("less is more", @i18n.translate("simple"))
  end

  def test_nested_translate_string
    assert_equal("something wasn't right", @i18n.translate("errors.syntax.oops"))
  end

  def test_single_string_interpolation
    assert_equal("something different", @i18n.translate("whatever", something: "different"))
  end

  # def test_raises_translation_error_on_undefined_interpolation_key
  #   assert_raises I18n::TranslationError do
  #     @i18n.translate("whatever", :oopstypos => "yes")
  #   end
  # end

  def test_raises_unknown_translation
    assert_raises(I18n::TranslationError) do
      @i18n.translate("doesnt_exist")
    end
  end

  def test_sets_default_path_to_en
    assert_equal(I18n::DEFAULT_LOCALE, I18n.new.path)
  end
end