-
-
Notifications
You must be signed in to change notification settings - Fork 760
Japanese letters get garbled in error messages. #2570
Comments
Are you able to pass the test? (e.g is it the expectation code thats wrong too? or just the differ?) |
Thanks for the quick response. |
Can you provide us a reproduction script? You can look at https://github.com/rspec/rspec-core/blob/master/REPORT_TEMPLATE.md |
Here is the reproduction script. #-*- coding: CP932 -*-
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "rspec", "3.7.0" # Activate the gem and version you are reporting the issue against.
end
puts "Ruby version is: #{RUBY_VERSION}"
require 'rspec/autorun'
RSpec.describe 'Output' do
it "テスト実行結果の文字列にはメッセージが出力されること" do
msg = ""
msg.include?("テスト実行結果".encode("CP932")).should be_truthy
end
end The result of the code above looks like this. Ruby version is: 2.4.0
F
Failures:
1) Output テスト実行結果の文字列にはメッセージが出力されること
Failure/Error: msg.include?("?e?X?g???s????".encode("CP932")).should be_truthy
expected: truthy value
got: false
# rspec_report.rb:10:in `block (2 levels) in <main>' If you pass the expected value which is |
Hello @shusuke-nakamura I'm not a professional of encoding but I have a different error when I try to run your script on ruby-2.4.4 and ruby-2.5.1.
Who link to another RSpec issue: rspec/rspec#28 Maybe looking at this one can help: https://tickets.puppetlabs.com/browse/PUP-8368 I will look at rspec/rspec#28 first then go back on this one. Side note. Are you using Windows? |
I'm able to reproduce with: --- a/lib/rspec/core/formatters/exception_presenter.rb
+++ b/lib/rspec/core/formatters/exception_presenter.rb
@@ -1,4 +1,4 @@
-# encoding: utf-8
+# encoding: CP932
|
@benoittgt |
When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - rspec#2570 - https://github.com/rspec/rspec-core/issues/2543
When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - rspec#2570 - https://github.com/rspec/rspec-core/issues/2543 For Ruby 1.8.7 We are following the same behavior as for rspec-support https://github.com/rspec/rspec-support/blob/9940a8656071655b807f772f36101b4d27f1b67d/lib/rspec/support/spec/string_matcher.rb#L8
When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - rspec#2570 - https://github.com/rspec/rspec-core/issues/2543 For Ruby 1.8.7 We are following the same behavior as for rspec-support https://github.com/rspec/rspec-support/blob/9940a8656071655b807f772f36101b4d27f1b67d/lib/rspec/support/spec/string_matcher.rb#L8
It should be fixed with #2575 Do you think you can try it @shusuke-nakamura? We will reopen the issue if it is not fixed. |
When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - #2570 - https://github.com/rspec/rspec-core/issues/2543 For Ruby 1.8.7 We are following the same behavior as for rspec-support https://github.com/rspec/rspec-support/blob/9940a8656071655b807f772f36101b4d27f1b67d/lib/rspec/support/spec/string_matcher.rb#L8
When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - rspec#2570 - https://github.com/rspec/rspec-core/issues/2543 For Ruby 1.8.7 We are following the same behavior as for rspec-support https://github.com/rspec/rspec-support/blob/9940a8656071655b807f772f36101b4d27f1b67d/lib/rspec/support/spec/string_matcher.rb#L8
…iles When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - rspec/rspec-core#2570 - https://github.com/rspec/rspec-core/issues/2543 For Ruby 1.8.7 We are following the same behavior as for rspec-support https://github.com/rspec/rspec-support/blob/9940a8656071655b807f772f36101b4d27f1b67d/lib/rspec/support/spec/string_matcher.rb#L8 --- This commit was imported from rspec/rspec-core@fce1978.
…iles When the user create a test with CP932 encoding and japanese chars RSpec fail to properly display characters or crash with the error: > Encoding::CompatibilityError: incompatible character encodings: Windows-31J and UTF-8 Fix: - rspec/rspec-core#2570 - https://github.com/rspec/rspec-core/issues/2543 For Ruby 1.8.7 We are following the same behavior as for rspec-support https://github.com/rspec/rspec-support/blob/9940a8656071655b807f772f36101b4d27f1b67d/lib/rspec/support/spec/string_matcher.rb#L8 --- This commit was imported from rspec/rspec-core@05611c5.
We are using rspec - core - 3.7.1, and tring to test files which encodings are set as 'CP932'.
When we run failing tests, Japanese letters in error messages get garbled.
For instance, if we run the test code below.
The excution result would look like this.
In the error message, 【テスト実行結果】 became '縲舌ユ繧ケ繝亥ョ溯。檎オ先棡縲?'.
Is there anyway to fix this issue?
The text was updated successfully, but these errors were encountered: