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

Add test of EUC-JP encoding.

This commit is contained in:
Andy Brody 2015-03-13 18:48:17 -07:00
parent 562c6edebf
commit 8b8731388f
3 changed files with 20 additions and 2 deletions

1
spec/integration/_lib.rb Normal file
View file

@ -0,0 +1 @@
require_relative '../spec_helper'

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
require 'spec_helper' require_relative '_lib'
describe RestClient do describe RestClient do
@ -69,5 +69,22 @@ describe RestClient do
}.should raise_error(Encoding::UndefinedConversionError) }.should raise_error(Encoding::UndefinedConversionError)
response.valid_encoding?.should eq true response.valid_encoding?.should eq true
end end
it 'handles euc-jp' do
body = "\xA4\xA2\xA4\xA4\xA4\xA6\xA4\xA8\xA4\xAA".
force_encoding(Encoding::BINARY)
body_utf8 = 'あいうえお'
body_utf8.encoding.should eq Encoding::UTF_8
stub_request(:get, 'www.example.com').to_return(
:body => body, :status => 200, :headers => {
'Content-Type' => 'text/plain; charset=EUC-JP'
})
response = RestClient.get 'www.example.com'
response.encoding.should eq Encoding::EUC_JP
response.valid_encoding?.should eq true
response.length.should eq 5
response.encode('utf-8').should eq body_utf8
end
end end
end end

View file

@ -1,4 +1,4 @@
require 'spec_helper' require_relative '_lib'
describe RestClient::Request do describe RestClient::Request do
before(:all) do before(:all) do