Skip to content

Commit f744777

Browse files
committed
Isolate test from system charset environment
Signed-off-by: Jongmin Kim <[email protected]>
1 parent 04d7560 commit f744777

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spec/actions/inject_into_file_spec.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,15 @@ def file
105105
end
106106

107107
it "can insert chinese" do
108-
invoke! "doc/README.zh", "\n中文", :after => "__start__"
109-
expect(File.read(File.join(destination_root, "doc/README.zh"))).to eq("__start__\n中文\n说明\n__end__\n")
108+
encoding_original = Encoding.default_external
109+
110+
begin
111+
Encoding.default_external = Encoding.find("UTF-8")
112+
invoke! "doc/README.zh", "\n中文", :after => "__start__"
113+
expect(File.read(File.join(destination_root, "doc/README.zh"))).to eq("__start__\n中文\n说明\n__end__\n")
114+
ensure
115+
Encoding.default_external = encoding_original
116+
end
110117
end
111118
end
112119

0 commit comments

Comments
 (0)