-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
performance: remove unnecessary i18n locale reload (#2723)
* Remove unnecessary i18n reload I18n is reloaded whenever load_path are set, so an additional reload is not needed and only increases load time. * Test that faker and i18n are loaded properly
- Loading branch information
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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' | ||
gemfile do | ||
source 'https://rubygems.org' | ||
gem 'minitest' | ||
gem 'i18n' | ||
end | ||
require 'minitest/autorun' | ||
require 'i18n' | ||
class TestI18nLoad < Minitest::Test | ||
def test_faker_i18n | ||
I18n.available_locales = [:en] | ||
refute_predicate I18n.backend, :initialized? | ||
I18n.translate('doesnt matter just triggering a lookup') | ||
assert_predicate I18n.backend, :initialized? | ||
assert require File.expand_path('#{File.dirname(__FILE__)}/../lib/faker') | ||
assert Faker::Name.name | ||
end | ||
end | ||
RUBY | ||
|
||
cmd = %( ruby -e "#{code}" ) | ||
output, status = Open3.capture2e(cmd) | ||
|
||
assert_equal 0, status, output | ||
end | ||
end |