-
-
Notifications
You must be signed in to change notification settings - Fork 753
Handle RSpec description with japanese char in CP932 encoded files #2575
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,23 @@ module RSpec::Core | |
EOS | ||
end | ||
|
||
if String.method_defined?(:encoding) | ||
it 'allows the caller to add encoded description' do | ||
the_presenter = Formatters::ExceptionPresenter.new(exception, example, | ||
:description => "ジ".encode("CP932")) | ||
|
||
expect(the_presenter.fully_formatted(1)).to eq(<<-EOS.gsub(/^ +\|/, '')) | ||
| | ||
| 1) ジ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not this character on windows, which is why appveyor is failing, it comes back as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hitanaka156 are you on windows? It'd be good to know what this is supposed to do, I'd be half happy pending this test on windows with a note explaining. (Correct behaviour on posix only is better than no correct behaviour). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm ok with this. Thanks for the explanation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error is
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just surprised its the replacement character on windows |
||
| Failure/Error: # The failure happened here!#{ encoding_check } | ||
| | ||
| Boom | ||
| Bam | ||
| # ./spec/rspec/core/formatters/exception_presenter_spec.rb:#{line_num} | ||
EOS | ||
end | ||
end | ||
|
||
it 'allows the caller to omit the description' do | ||
the_presenter = Formatters::ExceptionPresenter.new(exception, example, | ||
:detail_formatter => Proc.new { "Detail!" }, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this do? Forgive my ignorance..
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I learned this yesterday. I changed the commit message to add more info.
chp
is for "change code page" (https://ss64.com/nt/chcp.html) and 65001 is the code for UTF-8. By doing this command you enforce UTF-8 locale for the next command.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to do that? Seems that we want to test we work in non UTF-8 environments...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But for me, if you don't set the correct local it will fail for every representation of strings with Japanese characters. I will run the command with Japanese locale https://docs.microsoft.com/en-us/windows/desktop/intl/code-page-identifiers to validate the correct behavior and also try to see what is the default local for appveyor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern here is that we want to work with the console mode being japanese, not force it to utf-8
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay @JonRowe. I am thinking every day about this open PR and other things I have to do on RSpec repos. 😥
I ran a build with
chcp
to display the default encoding of app veyor machine.437 is for "United States". - source
So I think by doing this we are going in the right direction. 437 encoding is probably not meant to display Unicode char, we have to change it.
Related StackOverFlow answer https://stackoverflow.com/a/3781095/2747638
or https://superuser.com/questions/625866/cmd-how-to-use-non-english-characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can drop the last commit when you are ok with the existing work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I honestly don't know any better so lets drop that commit and merge this, get a release out and see what affect this makes for our friends with problems