File: test_i18n_reload.rb

package info (click to toggle)
ruby-faker 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,360 kB
  • sloc: ruby: 20,654; makefile: 6; sh: 6
file content (39 lines) | stat: -rw-r--r-- 842 bytes parent folder | download
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'
require 'open3'

class TestI18nLoad < Test::Unit::TestCase
  def test_faker_i18n
    # run this code in a subshell to test require faker
    # and proper initialization of i18n.
    code = <<-RUBY
      require 'bundler/inline'
      require 'test/unit'

      gemfile do
        source 'https://rubygems.org'
        gem 'i18n'
      end

      require 'i18n'

      class TestI18nLoad < Test::Unit::TestCase
        def test_faker_i18n
          I18n.available_locales = [:en]

          refute I18n.backend.initialized?

          I18n.translate('doesnt matter just triggering a lookup')

          assert I18n.backend.initialized?
        end
      end
    RUBY

    cmd = %( ruby -e "#{code}" )
    output, status = Open3.capture2e(cmd)

    assert_equal(0, status, output)
  end
end