HTTPServerException is deprecated

* spec/ruby/library/net/http/HTTPClientException_spec.rb: add.
* spec/ruby/library/net/http/HTTPServerException_spec.rb: check deprecated message.
* spec/ruby/library/net/http/httpresponse/*_spec.rb: use HTTPClientException instead of HTTPServerException.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2018-06-14 06:41:09 +00:00
parent 99cc20519b
commit fa0f702c5b
6 changed files with 58 additions and 10 deletions

View File

@ -0,0 +1,14 @@
require_relative '../../../spec_helper'
require 'net/http'
ruby_version_is "2.6" do
describe "Net::HTTPClientException" do
it "is a subclass of Net::ProtoServerError" do
Net::HTTPClientException.should < Net::ProtoServerError
end
it "includes the Net::HTTPExceptions module" do
Net::HTTPClientException.should < Net::HTTPExceptions
end
end
end

View File

@ -1,12 +1,26 @@
require_relative '../../../spec_helper'
require 'net/http'
describe "Net::HTTPServerException" do
it "is a subclass of Net::ProtoServerError" do
Net::HTTPServerException.should < Net::ProtoServerError
end
ruby_version_is ""..."2.6" do
describe "Net::HTTPServerException" do
it "is a subclass of Net::ProtoServerError" do
Net::HTTPServerException.should < Net::ProtoServerError
end
it "includes the Net::HTTPExceptions module" do
Net::HTTPServerException.should < Net::HTTPExceptions
it "includes the Net::HTTPExceptions module" do
Net::HTTPServerException.should < Net::HTTPExceptions
end
end
end
ruby_version_is "2.6" do
describe "Net::HTTPServerException" do
it "is a subclass of Net::ProtoServerError and is warned as deprecated" do
lambda { Net::HTTPServerException.should < Net::ProtoServerError }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
end
it "includes the Net::HTTPExceptions module and is warned as deprecated" do
lambda { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/)
end
end
end

View File

@ -16,7 +16,12 @@ describe "Net::HTTPResponse#error!" do
lambda { res.error! }.should raise_error(Net::HTTPRetriableError)
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
lambda { res.error! }.should raise_error(Net::HTTPServerException)
ruby_version_is ""..."2.6" do
lambda { res.error! }.should raise_error(Net::HTTPServerException)
end
ruby_version_is "2.6" do
lambda { res.error! }.should raise_error(Net::HTTPClientException)
end
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
lambda { res.error! }.should raise_error(Net::HTTPFatalError)

View File

@ -16,7 +16,12 @@ describe "Net::HTTPResponse#error_type" do
res.error_type.should == Net::HTTPRetriableError
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
res.error_type.should == Net::HTTPServerException
ruby_version_is ""..."2.6" do
res.error_type.should == Net::HTTPServerException
end
ruby_version_is "2.6" do
res.error_type.should == Net::HTTPClientException
end
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
res.error_type.should == Net::HTTPFatalError

View File

@ -7,7 +7,12 @@ describe "Net::HTTPResponse.exception_type" do
Net::HTTPInformation.exception_type.should == Net::HTTPError
Net::HTTPSuccess.exception_type.should == Net::HTTPError
Net::HTTPRedirection.exception_type.should == Net::HTTPRetriableError
Net::HTTPClientError.exception_type.should == Net::HTTPServerException
ruby_version_is ""..."2.6" do
Net::HTTPClientError.exception_type.should == Net::HTTPServerException
end
ruby_version_is "2.6" do
Net::HTTPClientError.exception_type.should == Net::HTTPClientException
end
Net::HTTPServerError.exception_type.should == Net::HTTPFatalError
end
end

View File

@ -16,7 +16,12 @@ describe "Net::HTTPResponse#value" do
lambda { res.value }.should raise_error(Net::HTTPRetriableError)
res = Net::HTTPClientError.new("1.0", "4xx", "test response")
lambda { res.value }.should raise_error(Net::HTTPServerException)
ruby_version_is ""..."2.6" do
lambda { res.value }.should raise_error(Net::HTTPServerException)
end
ruby_version_is "2.6" do
lambda { res.value }.should raise_error(Net::HTTPClientException)
end
res = Net::HTTPServerError.new("1.0", "5xx", "test response")
lambda { res.value }.should raise_error(Net::HTTPFatalError)