From f744777ff02ce1310149a1f6824528041c12fe59 Mon Sep 17 00:00:00 2001 From: Jongmin Kim Date: Sun, 16 Jun 2019 06:15:17 +0900 Subject: [PATCH] Isolate test from system charset environment Signed-off-by: Jongmin Kim --- spec/actions/inject_into_file_spec.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/actions/inject_into_file_spec.rb b/spec/actions/inject_into_file_spec.rb index f34a677c0..1da222fb2 100644 --- a/spec/actions/inject_into_file_spec.rb +++ b/spec/actions/inject_into_file_spec.rb @@ -105,8 +105,15 @@ def file end it "can insert chinese" do - invoke! "doc/README.zh", "\n中文", :after => "__start__" - expect(File.read(File.join(destination_root, "doc/README.zh"))).to eq("__start__\n中文\n说明\n__end__\n") + encoding_original = Encoding.default_external + + begin + Encoding.default_external = Encoding.find("UTF-8") + invoke! "doc/README.zh", "\n中文", :after => "__start__" + expect(File.read(File.join(destination_root, "doc/README.zh"))).to eq("__start__\n中文\n说明\n__end__\n") + ensure + Encoding.default_external = encoding_original + end end end