mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Update to ruby/spec@a6b8805
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6530b14cee
commit
8c5b60eb22
218 changed files with 4069 additions and 328 deletions
|
@ -35,7 +35,7 @@ module NetFTPSpecs
|
|||
response @connect_message || "220 Dummy FTP Server ready!"
|
||||
|
||||
begin
|
||||
while command = @socket.recv(1024)
|
||||
while command = @socket.gets
|
||||
command, argument = command.chomp.split(" ", 2)
|
||||
|
||||
if command == "QUIT"
|
||||
|
@ -229,8 +229,12 @@ module NetFTPSpecs
|
|||
end
|
||||
end
|
||||
|
||||
def stat
|
||||
self.response("211 System status, or system help reply. (STAT)")
|
||||
def stat(param = :default)
|
||||
if param == :default
|
||||
self.response("211 System status, or system help reply. (STAT)")
|
||||
else
|
||||
self.response("211 System status, or system help reply. (STAT #{param})")
|
||||
end
|
||||
end
|
||||
|
||||
def stor(file)
|
||||
|
|
|
@ -22,6 +22,12 @@ describe "Net::FTP#status" do
|
|||
@ftp.last_response.should == "211 System status, or system help reply. (STAT)\n"
|
||||
end
|
||||
|
||||
ruby_version_is "2.4" do
|
||||
it "sends the STAT command with an optional parameter to the server" do
|
||||
@ftp.status("/pub").should == "211 System status, or system help reply. (STAT /pub)\n"
|
||||
end
|
||||
end
|
||||
|
||||
it "returns the received information" do
|
||||
@ftp.status.should == "211 System status, or system help reply. (STAT)\n"
|
||||
end
|
||||
|
|
|
@ -42,6 +42,17 @@ module NetHTTPSpecs
|
|||
end
|
||||
end
|
||||
|
||||
class RequestBasicAuthServlet < SpecServlet
|
||||
def reply(req, res)
|
||||
res.content_type = "text/plain"
|
||||
|
||||
WEBrick::HTTPAuth.basic_auth(req, res, "realm") do |user, pass|
|
||||
res.body = "username: #{user}\npassword: #{pass}"
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
@server = nil
|
||||
@server_thread = nil
|
||||
|
@ -69,6 +80,7 @@ module NetHTTPSpecs
|
|||
@server.mount('/request', RequestServlet)
|
||||
@server.mount("/request/body", RequestBodyServlet)
|
||||
@server.mount("/request/header", RequestHeaderServlet)
|
||||
@server.mount("/request/basic_auth", RequestBasicAuthServlet)
|
||||
|
||||
@server_thread = @server.start
|
||||
end
|
||||
|
|
|
@ -1,7 +1,45 @@
|
|||
require File.expand_path('../../../../../spec_helper', __FILE__)
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
require File.expand_path('../fixtures/http_server', __FILE__)
|
||||
|
||||
ruby_version_is '2.4' do
|
||||
describe "Net::HTTP.post" do
|
||||
before :each do
|
||||
NetHTTPSpecs.start_server
|
||||
end
|
||||
|
||||
after :each do
|
||||
NetHTTPSpecs.stop_server
|
||||
end
|
||||
|
||||
it "sends post request to the specified URI and returns response" do
|
||||
response = Net::HTTP.post(
|
||||
URI("http://localhost:#{NetHTTPSpecs.port}/request"),
|
||||
'{ "q": "ruby", "max": "50" }',
|
||||
"Content-Type" => "application/json")
|
||||
response.body.should == "Request type: POST"
|
||||
end
|
||||
|
||||
it "returns a Net::HTTPResponse" do
|
||||
response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request"), "test=test")
|
||||
response.should be_kind_of(Net::HTTPResponse)
|
||||
end
|
||||
|
||||
it "sends Content-Type: application/x-www-form-urlencoded by default" do
|
||||
response = Net::HTTP.post(URI("http://localhost:#{NetHTTPSpecs.port}/request/header"), "test=test")
|
||||
response.body.should include('"content-type"=>["application/x-www-form-urlencoded"]')
|
||||
end
|
||||
|
||||
it "does not support HTTP Basic Auth" do
|
||||
response = Net::HTTP.post(
|
||||
URI("http://john:qwerty@localhost:#{NetHTTPSpecs.port}/request/basic_auth"),
|
||||
"test=test")
|
||||
response.body.should == "username: \npassword: "
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Net::HTTP#post" do
|
||||
before :each do
|
||||
NetHTTPSpecs.start_server
|
||||
|
@ -36,3 +74,4 @@ describe "Net::HTTP#post" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ describe "Net::HTTP::Get" do
|
|||
Net::HTTP::Get::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Get::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -32,7 +32,7 @@ describe "Net::HTTP::Head" do
|
|||
Net::HTTP::Head::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has no Respone Body" do
|
||||
it "has no Response Body" do
|
||||
Net::HTTP::Head::RESPONSE_HAS_BODY.should be_false
|
||||
end
|
||||
end
|
||||
|
@ -50,7 +50,7 @@ describe "Net::HTTP::Post" do
|
|||
Net::HTTP::Post::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Post::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -68,7 +68,7 @@ describe "Net::HTTP::Put" do
|
|||
Net::HTTP::Put::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Put::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ describe "Net::HTTP::Delete" do
|
|||
Net::HTTP::Delete::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Delete::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ describe "Net::HTTP::Options" do
|
|||
Net::HTTP::Options::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has no Respone Body" do
|
||||
it "has no Response Body" do
|
||||
Net::HTTP::Options::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -122,7 +122,7 @@ describe "Net::HTTP::Trace" do
|
|||
Net::HTTP::Trace::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Trace::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -140,7 +140,7 @@ describe "Net::HTTP::Propfind" do
|
|||
Net::HTTP::Propfind::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Propfind::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -158,7 +158,7 @@ describe "Net::HTTP::Proppatch" do
|
|||
Net::HTTP::Proppatch::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -176,7 +176,7 @@ describe "Net::HTTP::Mkcol" do
|
|||
Net::HTTP::Mkcol::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -194,7 +194,7 @@ describe "Net::HTTP::Copy" do
|
|||
Net::HTTP::Copy::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Copy::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -212,7 +212,7 @@ describe "Net::HTTP::Move" do
|
|||
Net::HTTP::Move::REQUEST_HAS_BODY.should be_false
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Move::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -230,7 +230,7 @@ describe "Net::HTTP::Lock" do
|
|||
Net::HTTP::Lock::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Lock::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
@ -248,7 +248,7 @@ describe "Net::HTTP::Unlock" do
|
|||
Net::HTTP::Unlock::REQUEST_HAS_BODY.should be_true
|
||||
end
|
||||
|
||||
it "has a Respone Body" do
|
||||
it "has a Response Body" do
|
||||
Net::HTTP::Unlock::RESPONSE_HAS_BODY.should be_true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ describe "Net::HTTPHeader#content_length=" do
|
|||
it "removes the 'Content-Length' entry if passed false or nil" do
|
||||
@headers["Content-Length"] = "123"
|
||||
@headers.content_length = nil
|
||||
@headers["Content-Lenght"].should be_nil
|
||||
@headers["Content-Length"].should be_nil
|
||||
end
|
||||
|
||||
it "sets the 'Content-Length' entry to the passed value" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue