mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
Fix default Net::HTTP encoding in Windows tests.
It turns out that Net::HTTP seems to always use UTF-8 as the default encoding, even when Encoding.default_external is Encoding::IBM437 (as it is on Windows/mingw).
This commit is contained in:
parent
b98798e632
commit
0d8f777fec
2 changed files with 7 additions and 5 deletions
|
@ -8,8 +8,8 @@ module RestClient
|
|||
# text. This differs from the older RFC 2616 behavior, which specifies
|
||||
# using ISO-8859-1 for text/* content types without a charset.
|
||||
#
|
||||
# Strings will effectively end up using `Encoding.default_external` when
|
||||
# this method returns nil.
|
||||
# Strings will use the default encoding when this method returns nil. This
|
||||
# default is likely to be UTF-8 for Ruby >= 2.0
|
||||
#
|
||||
# @param headers [Hash<Symbol,String>]
|
||||
#
|
||||
|
|
|
@ -88,14 +88,15 @@ describe RestClient do
|
|||
expect(response.encode('utf-8')).to eq body_utf8
|
||||
end
|
||||
|
||||
it 'defaults to Encoding.default_external' do
|
||||
it 'defaults to the default encoding' do
|
||||
stub_request(:get, 'www.example.com').to_return(
|
||||
body: 'abc', status: 200, headers: {
|
||||
'Content-Type' => 'text/plain'
|
||||
})
|
||||
|
||||
response = RestClient.get 'www.example.com'
|
||||
expect(response.encoding).to eq Encoding.default_external
|
||||
# expect(response.encoding).to eq Encoding.default_external
|
||||
expect(response.encoding).to eq Encoding::UTF_8
|
||||
end
|
||||
|
||||
it 'handles invalid encoding' do
|
||||
|
@ -105,7 +106,8 @@ describe RestClient do
|
|||
})
|
||||
|
||||
response = RestClient.get 'www.example.com'
|
||||
expect(response.encoding).to eq Encoding.default_external
|
||||
# expect(response.encoding).to eq Encoding.default_external
|
||||
expect(response.encoding).to eq Encoding::UTF_8
|
||||
end
|
||||
|
||||
it 'leaves images as binary' do
|
||||
|
|
Loading…
Reference in a new issue