diff options
Diffstat (limited to 'spec/ruby/library/net/http')
18 files changed, 47 insertions, 47 deletions
diff --git a/spec/ruby/library/net/http/HTTPServerException_spec.rb b/spec/ruby/library/net/http/HTTPServerException_spec.rb index 3960effadd..87841ab499 100644 --- a/spec/ruby/library/net/http/HTTPServerException_spec.rb +++ b/spec/ruby/library/net/http/HTTPServerException_spec.rb @@ -16,11 +16,11 @@ 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/) + -> { 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/) + -> { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/) end end end diff --git a/spec/ruby/library/net/http/http/finish_spec.rb b/spec/ruby/library/net/http/http/finish_spec.rb index b031c58e2c..f98bc7be13 100644 --- a/spec/ruby/library/net/http/http/finish_spec.rb +++ b/spec/ruby/library/net/http/http/finish_spec.rb @@ -23,7 +23,7 @@ describe "Net::HTTP#finish" do describe "when self has not been started yet" do it "raises an IOError" do - lambda { @http.finish }.should raise_error(IOError) + -> { @http.finish }.should raise_error(IOError) end end end diff --git a/spec/ruby/library/net/http/http/get_print_spec.rb b/spec/ruby/library/net/http/http/get_print_spec.rb index 6174e3eb21..f59dd68c81 100644 --- a/spec/ruby/library/net/http/http/get_print_spec.rb +++ b/spec/ruby/library/net/http/http/get_print_spec.rb @@ -14,7 +14,7 @@ describe "Net::HTTP.get_print" do describe "when passed URI" do it "it prints the body of the specified uri to $stdout" do - lambda do + -> do Net::HTTP.get_print URI.parse("http://localhost:#{@port}/") end.should output(/This is the index page\./) end @@ -22,7 +22,7 @@ describe "Net::HTTP.get_print" do describe "when passed host, path, port" do it "it prints the body of the specified uri to $stdout" do - lambda do + -> do Net::HTTP.get_print 'localhost', "/", @port end.should output(/This is the index page\./) end diff --git a/spec/ruby/library/net/http/http/set_debug_output_spec.rb b/spec/ruby/library/net/http/http/set_debug_output_spec.rb index e0fe4796da..94b6f4499d 100644 --- a/spec/ruby/library/net/http/http/set_debug_output_spec.rb +++ b/spec/ruby/library/net/http/http/set_debug_output_spec.rb @@ -28,6 +28,6 @@ describe "Net::HTTP#set_debug_output when passed io" do it "outputs a warning when the connection has already been started" do @http.start - lambda { @http.set_debug_output(StringIO.new) }.should complain(/Net::HTTP#set_debug_output called after HTTP started/) + -> { @http.set_debug_output(StringIO.new) }.should complain(/Net::HTTP#set_debug_output called after HTTP started/) end end diff --git a/spec/ruby/library/net/http/http/start_spec.rb b/spec/ruby/library/net/http/http/start_spec.rb index e23f9183f7..a2768eed18 100644 --- a/spec/ruby/library/net/http/http/start_spec.rb +++ b/spec/ruby/library/net/http/http/start_spec.rb @@ -81,7 +81,7 @@ describe "Net::HTTP#start" do describe "when self has already been started" do it "raises an IOError" do @http.start - lambda { @http.start }.should raise_error(IOError) + -> { @http.start }.should raise_error(IOError) end end diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb index 9b04bffb2e..7d081939b8 100644 --- a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb +++ b/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb @@ -13,7 +13,7 @@ describe "Net::HTTPGenericRequest#body_exist?" do describe "when $VERBOSE is true" do it "emits a warning" do request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - lambda { + -> { request.body_exist? }.should complain(/body_exist\? is obsolete/, verbose: true) end diff --git a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb index 90e158a159..da5b1a63be 100644 --- a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb +++ b/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb @@ -125,7 +125,7 @@ describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do "Content-Type" => "text/html") request.body_stream = StringIO.new("Some Content") - lambda { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should raise_error(ArgumentError) + -> { request.exec(@buffered_socket, "1.1", "/some/other/path") }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb index ef2edc019a..7494c69173 100644 --- a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb +++ b/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb @@ -13,9 +13,9 @@ describe "Net::HTTPGenericRequest#set_body_internal when passed string" do it "raises an ArgumentError when the body or body_stream of self have already been set" do @request.body = "Some Content" - lambda { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) + -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) @request.body_stream = "Some Content" - lambda { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) + -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) end end diff --git a/spec/ruby/library/net/http/httpheader/content_length_spec.rb b/spec/ruby/library/net/http/httpheader/content_length_spec.rb index 44c971c98e..e344817e82 100644 --- a/spec/ruby/library/net/http/httpheader/content_length_spec.rb +++ b/spec/ruby/library/net/http/httpheader/content_length_spec.rb @@ -13,7 +13,7 @@ describe "Net::HTTPHeader#content_length" do it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Length' header entry has an invalid format" do @headers["Content-Length"] = "invalid" - lambda { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError) end it "returns the value of the 'Content-Length' header entry as an Integer" do diff --git a/spec/ruby/library/net/http/httpheader/content_range_spec.rb b/spec/ruby/library/net/http/httpheader/content_range_spec.rb index 23dc92348b..ba75f9a9a1 100644 --- a/spec/ruby/library/net/http/httpheader/content_range_spec.rb +++ b/spec/ruby/library/net/http/httpheader/content_range_spec.rb @@ -21,12 +21,12 @@ describe "Net::HTTPHeader#content_range" do it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do @headers["Content-Range"] = "invalid" - lambda { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes 123-abc" - lambda { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes abc-123" - lambda { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) end end diff --git a/spec/ruby/library/net/http/httpheader/fetch_spec.rb b/spec/ruby/library/net/http/httpheader/fetch_spec.rb index 4d608cdb0d..ea15679acb 100644 --- a/spec/ruby/library/net/http/httpheader/fetch_spec.rb +++ b/spec/ruby/library/net/http/httpheader/fetch_spec.rb @@ -25,7 +25,7 @@ describe "Net::HTTPHeader#fetch" do end it "returns nil when there is no entry for the passed key" do - lambda { @headers.fetch("my-header") }.should raise_error(IndexError) + -> { @headers.fetch("my-header") }.should raise_error(IndexError) end end diff --git a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb b/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb index 35768b4e7e..efc5e7d0b2 100644 --- a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb +++ b/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb @@ -14,7 +14,7 @@ describe "Net::HTTPHeader#initialize_http_header when passed Hash" do end it "complains about duplicate keys when in verbose mode" do - lambda do + -> do @headers.initialize_http_header("My-Header" => "test", "my-header" => "another test") end.should complain(/duplicated HTTP header/, verbose: true) end diff --git a/spec/ruby/library/net/http/httpheader/range_length_spec.rb b/spec/ruby/library/net/http/httpheader/range_length_spec.rb index 4415c8e5ba..b8fce4f690 100644 --- a/spec/ruby/library/net/http/httpheader/range_length_spec.rb +++ b/spec/ruby/library/net/http/httpheader/range_length_spec.rb @@ -21,12 +21,12 @@ describe "Net::HTTPHeader#range_length" do it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do @headers["Content-Range"] = "invalid" - lambda { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes 123-abc" - lambda { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) @headers["Content-Range"] = "bytes abc-123" - lambda { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) end end diff --git a/spec/ruby/library/net/http/httpheader/range_spec.rb b/spec/ruby/library/net/http/httpheader/range_spec.rb index 5f06e03a1c..005177f6be 100644 --- a/spec/ruby/library/net/http/httpheader/range_spec.rb +++ b/spec/ruby/library/net/http/httpheader/range_spec.rb @@ -28,18 +28,18 @@ describe "Net::HTTPHeader#range" do it "raises a Net::HTTPHeaderSyntaxError when the 'Range' has an invalid format" do @headers["Range"] = "invalid" - lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) @headers["Range"] = "bytes 123-abc" - lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) @headers["Range"] = "bytes abc-123" - lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the 'Range' was not specified" do @headers["Range"] = "bytes=-" - lambda { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) end end diff --git a/spec/ruby/library/net/http/httpheader/shared/set_range.rb b/spec/ruby/library/net/http/httpheader/shared/set_range.rb index 6a98edbe10..87f51d46f3 100644 --- a/spec/ruby/library/net/http/httpheader/shared/set_range.rb +++ b/spec/ruby/library/net/http/httpheader/shared/set_range.rb @@ -50,15 +50,15 @@ describe :net_httpheader_set_range, shared: true do end it "raises a Net::HTTPHeaderSyntaxError when the first Range element is negative" do - lambda { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the last Range element is negative" do - lambda { @headers.send(@method, 10..-5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10..-5) }.should raise_error(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when the last Range element is smaller than the first" do - lambda { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) end end @@ -75,15 +75,15 @@ describe :net_httpheader_set_range, shared: true do end it "raises a Net::HTTPHeaderSyntaxError when start is negative" do - lambda { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when start + length is negative" do - lambda { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError) end it "raises a Net::HTTPHeaderSyntaxError when length is negative" do - lambda { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError) + -> { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError) end end end diff --git a/spec/ruby/library/net/http/httpresponse/error_spec.rb b/spec/ruby/library/net/http/httpresponse/error_spec.rb index a3a3cee162..d2b2f53d89 100644 --- a/spec/ruby/library/net/http/httpresponse/error_spec.rb +++ b/spec/ruby/library/net/http/httpresponse/error_spec.rb @@ -4,26 +4,26 @@ require 'net/http' describe "Net::HTTPResponse#error!" do it "raises self's class 'EXCEPTION_TYPE' Exception" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - lambda { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should raise_error(Net::HTTPError) res = Net::HTTPInformation.new("1.0", "1xx", "test response") - lambda { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should raise_error(Net::HTTPError) res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - lambda { res.error! }.should raise_error(Net::HTTPError) + -> { res.error! }.should raise_error(Net::HTTPError) res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - lambda { res.error! }.should raise_error(Net::HTTPRetriableError) + -> { res.error! }.should raise_error(Net::HTTPRetriableError) res = Net::HTTPClientError.new("1.0", "4xx", "test response") ruby_version_is ""..."2.6" do - lambda { res.error! }.should raise_error(Net::HTTPServerException) + -> { res.error! }.should raise_error(Net::HTTPServerException) end ruby_version_is "2.6" do - lambda { res.error! }.should raise_error(Net::HTTPClientException) + -> { 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) + -> { res.error! }.should raise_error(Net::HTTPFatalError) end end diff --git a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb b/spec/ruby/library/net/http/httpresponse/read_body_spec.rb index a050eca594..99d8e5fa88 100644 --- a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb +++ b/spec/ruby/library/net/http/httpresponse/read_body_spec.rb @@ -40,7 +40,7 @@ describe "Net::HTTPResponse#read_body" do it "raises an IOError if called a second time" do @res.reading_body(@socket, true) do @res.read_body("") - lambda { @res.read_body("") }.should raise_error(IOError) + -> { @res.read_body("") }.should raise_error(IOError) end end end @@ -70,7 +70,7 @@ describe "Net::HTTPResponse#read_body" do it "raises an IOError if called a second time" do @res.reading_body(@socket, true) do @res.read_body {} - lambda { @res.read_body {} }.should raise_error(IOError) + -> { @res.read_body {} }.should raise_error(IOError) end end end @@ -78,7 +78,7 @@ describe "Net::HTTPResponse#read_body" do describe "when passed buffer and block" do it "raises an ArgumentError" do @res.reading_body(@socket, true) do - lambda { @res.read_body("") {} }.should raise_error(ArgumentError) + -> { @res.read_body("") {} }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/library/net/http/httpresponse/value_spec.rb b/spec/ruby/library/net/http/httpresponse/value_spec.rb index 1b19d1d6f7..4a5930d4e5 100644 --- a/spec/ruby/library/net/http/httpresponse/value_spec.rb +++ b/spec/ruby/library/net/http/httpresponse/value_spec.rb @@ -4,26 +4,26 @@ require 'net/http' describe "Net::HTTPResponse#value" do it "raises an HTTP error for non 2xx HTTP Responses" do res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - lambda { res.value }.should raise_error(Net::HTTPError) + -> { res.value }.should raise_error(Net::HTTPError) res = Net::HTTPInformation.new("1.0", "1xx", "test response") - lambda { res.value }.should raise_error(Net::HTTPError) + -> { res.value }.should raise_error(Net::HTTPError) res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - lambda { res.value }.should_not raise_error(Net::HTTPError) + -> { res.value }.should_not raise_error(Net::HTTPError) res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - lambda { res.value }.should raise_error(Net::HTTPRetriableError) + -> { res.value }.should raise_error(Net::HTTPRetriableError) res = Net::HTTPClientError.new("1.0", "4xx", "test response") ruby_version_is ""..."2.6" do - lambda { res.value }.should raise_error(Net::HTTPServerException) + -> { res.value }.should raise_error(Net::HTTPServerException) end ruby_version_is "2.6" do - lambda { res.value }.should raise_error(Net::HTTPClientException) + -> { 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) + -> { res.value }.should raise_error(Net::HTTPFatalError) end end |