1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Add a couple more default encoding tests.

This commit is contained in:
Andy Brody 2015-03-14 12:19:59 -07:00
parent 8b8731388f
commit e52e24a095

View file

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
require_relative '_lib'
require 'base64'
describe RestClient do
@ -86,5 +87,27 @@ describe RestClient do
response.length.should eq 5
response.encode('utf-8').should eq body_utf8
end
it 'defaults to Encoding.default_external' do
stub_request(:get, 'www.example.com').to_return(
body: 'abc', status: 200, headers: {
'Content-Type' => 'text/plain'
})
response = RestClient.get 'www.example.com'
response.encoding.should eq Encoding.default_external
end
it 'leaves images as binary' do
gif = Base64.strict_decode64('R0lGODlhAQABAAAAADs=')
stub_request(:get, 'www.example.com').to_return(
body: gif, status: 200, headers: {
'Content-Type' => 'image/gif'
})
response = RestClient.get 'www.example.com'
response.encoding.should eq Encoding::BINARY
end
end
end