Encoding::UndefinedConversionError
ktimothy opened this issue · 4 comments
My test suite fails with error when trying to encode hostname:
.../rspec_junit_formatter-0.4.1/lib/rspec_junit_formatter.rb:173:in `encode': "\\xE2" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
irb(main):003:0> Socket.gethostname
=> "timofei.kovalev\xE2\x80\x99s-MacBook-Pro"
irb(main):004:0> Socket.gethostname.encoding
=> #<Encoding:ASCII-8BIT>
Yes, it looks like your hostname is indeed invalidly encoded?
Yep, this is definitely a "think different" stuff, and I have changed it, but I still think the formatter should not fail in such cases.
Ran into this issue today but with a different character
Encoding::UndefinedConversionError: "\x91" from ASCII-8BIT to UTF-8
\x91
or \u2018
which is LEFT SINGLE QUOTATION MARK
. Any chance we can add a replacement to replace this to '
or is that not okay?
Okay I discovered the issue -- we had test failure that spit out the following.
1) SomeTest when something happens
Failure/Error:
expect(
a_request(:get, "#{My::TestClient::HOST}/somepath?someparam=testparam"),
).to have_been_made.at_least_once
The request GET http://localhost:9000/somepath?someparam=testparam was expected to execute at least 1 time but it executed 0 times
The following requests were made:
POST http://obfuscated:8126/obfuscatedwith body '????start????`???
??G????name?rspec.example?service?' with headers {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', ...} was made 1 time
The string seems to be recognized as ASCII-8BIT when it is actually UTF8? I don't think I fully understand how encodings work but why does Ruby think the encoding here is ASCII-8BIT?