diff options
Diffstat (limited to 'spec/ruby/library/net')
218 files changed, 0 insertions, 7631 deletions
diff --git a/spec/ruby/library/net/FTPError_spec.rb b/spec/ruby/library/net/FTPError_spec.rb deleted file mode 100644 index 84128511db..0000000000 --- a/spec/ruby/library/net/FTPError_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../spec_helper' - -ruby_version_is ""..."3.1" do - require 'net/ftp' - - describe "Net::FTPError" do - it "is an Exception" do - Net::FTPError.should < Exception - end - end -end diff --git a/spec/ruby/library/net/FTPPermError_spec.rb b/spec/ruby/library/net/FTPPermError_spec.rb deleted file mode 100644 index 0da35e7d82..0000000000 --- a/spec/ruby/library/net/FTPPermError_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative '../../spec_helper' - -ruby_version_is ""..."3.1" do - require 'net/ftp' - - describe "Net::FTPPermError" do - it "is an Exception" do - Net::FTPPermError.should < Exception - end - - it "is a subclass of Net::FTPError" do - Net::FTPPermError.should < Net::FTPError - end - end -end diff --git a/spec/ruby/library/net/FTPProtoError_spec.rb b/spec/ruby/library/net/FTPProtoError_spec.rb deleted file mode 100644 index 20e30dd2dd..0000000000 --- a/spec/ruby/library/net/FTPProtoError_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative '../../spec_helper' - -ruby_version_is ""..."3.1" do - require 'net/ftp' - - describe "Net::FTPProtoError" do - it "is an Exception" do - Net::FTPProtoError.should < Exception - end - - it "is a subclass of Net::FTPError" do - Net::FTPPermError.should < Net::FTPError - end - end -end diff --git a/spec/ruby/library/net/FTPReplyError_spec.rb b/spec/ruby/library/net/FTPReplyError_spec.rb deleted file mode 100644 index cc774aabe5..0000000000 --- a/spec/ruby/library/net/FTPReplyError_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative '../../spec_helper' - -ruby_version_is ""..."3.1" do - require 'net/ftp' - - describe "Net::FTPReplyError" do - it "is an Exception" do - Net::FTPReplyError.should < Exception - end - - it "is a subclass of Net::FTPError" do - Net::FTPPermError.should < Net::FTPError - end - end -end diff --git a/spec/ruby/library/net/FTPTempError_spec.rb b/spec/ruby/library/net/FTPTempError_spec.rb deleted file mode 100644 index e2fbdfd842..0000000000 --- a/spec/ruby/library/net/FTPTempError_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative '../../spec_helper' - -ruby_version_is ""..."3.1" do - require 'net/ftp' - - describe "Net::FTPTempError" do - it "is an Exception" do - Net::FTPTempError.should < Exception - end - - it "is a subclass of Net::FTPError" do - Net::FTPPermError.should < Net::FTPError - end - end -end diff --git a/spec/ruby/library/net/ftp/abort_spec.rb b/spec/ruby/library/net/ftp/abort_spec.rb deleted file mode 100644 index ebdfed4b16..0000000000 --- a/spec/ruby/library/net/ftp/abort_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#abort" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the ABOR command to the server" do - -> { @ftp.abort }.should_not raise_error - end - - it "ignores the response" do - @ftp.abort - @ftp.last_response.should == "220 Dummy FTP Server ready!\n" - end - - it "returns the full response" do - @ftp.abort.should == "226 Closing data connection. (ABOR)\n" - end - - it "does not raise any error when the response code is 225" do - @server.should_receive(:abor).and_respond("225 Data connection open; no transfer in progress.") - -> { @ftp.abort }.should_not raise_error - end - - it "does not raise any error when the response code is 226" do - @server.should_receive(:abor).and_respond("226 Closing data connection.") - -> { @ftp.abort }.should_not raise_error - end - - it "raises a Net::FTPProtoError when the response code is 500" do - @server.should_receive(:abor).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPProtoError when the response code is 501" do - @server.should_receive(:abor).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPProtoError when the response code is 502" do - @server.should_receive(:abor).and_respond("502 Command not implemented.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPProtoError when the response code is 421" do - @server.should_receive(:abor).and_respond("421 Service not available, closing control connection.") - -> { @ftp.abort }.should raise_error(Net::FTPProtoError) - end - end -end diff --git a/spec/ruby/library/net/ftp/acct_spec.rb b/spec/ruby/library/net/ftp/acct_spec.rb deleted file mode 100644 index a960ae20a4..0000000000 --- a/spec/ruby/library/net/ftp/acct_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#acct" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "writes the ACCT command to the server" do - @ftp.acct("my_account") - @ftp.last_response.should == "230 User 'my_account' logged in, proceed. (ACCT)\n" - end - - it "returns nil" do - @ftp.acct("my_account").should == nil - end - - it "does not raise any error when the response code is 230" do - @server.should_receive(:acct).and_respond("230 User logged in, proceed.") - -> { @ftp.acct("my_account") }.should_not raise_error - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:acct).and_respond("530 Not logged in.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:acct).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:acct).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 503" do - @server.should_receive(:acct).and_respond("503 Bad sequence of commands.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:acct).and_respond("421 Service not available, closing control connection.") - -> { @ftp.acct("my_account") }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/binary_spec.rb b/spec/ruby/library/net/ftp/binary_spec.rb deleted file mode 100644 index da7e2d6c14..0000000000 --- a/spec/ruby/library/net/ftp/binary_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#binary" do - it "returns true when self is in binary mode" do - ftp = Net::FTP.new - ftp.binary.should be_true - - ftp.binary = false - ftp.binary.should be_false - end - end - - describe "Net::FTP#binary=" do - it "sets self to binary mode when passed true" do - ftp = Net::FTP.new - - ftp.binary = true - ftp.binary.should be_true - - ftp.binary = false - ftp.binary.should be_false - end - end -end diff --git a/spec/ruby/library/net/ftp/chdir_spec.rb b/spec/ruby/library/net/ftp/chdir_spec.rb deleted file mode 100644 index 741c3c845e..0000000000 --- a/spec/ruby/library/net/ftp/chdir_spec.rb +++ /dev/null @@ -1,102 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#chdir" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - describe "when switching to the parent directory" do - it "sends the 'CDUP' command to the server" do - @ftp.chdir("..") - @ftp.last_response.should == "200 Command okay. (CDUP)\n" - end - - it "returns nil" do - @ftp.chdir("..").should be_nil - end - - it "does not raise a Net::FTPPermError when the response code is 500" do - @server.should_receive(:cdup).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.chdir("..") }.should_not raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:cdup).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:cdup).and_respond("502 Command not implemented.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:cdup).and_respond("421 Service not available, closing control connection.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:cdup).and_respond("530 Not logged in.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:cdup).and_respond("550 Requested action not taken.") - -> { @ftp.chdir("..") }.should raise_error(Net::FTPPermError) - end - end - - it "writes the 'CWD' command with the passed directory to the socket" do - @ftp.chdir("test") - @ftp.last_response.should == "200 Command okay. (CWD test)\n" - end - - it "returns nil" do - @ftp.chdir("test").should be_nil - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:cwd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:cwd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:cwd).and_respond("502 Command not implemented.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:cwd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:cwd).and_respond("530 Not logged in.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:cwd).and_respond("550 Requested action not taken.") - -> { @ftp.chdir("test") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/close_spec.rb b/spec/ruby/library/net/ftp/close_spec.rb deleted file mode 100644 index 49cdf4dea7..0000000000 --- a/spec/ruby/library/net/ftp/close_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#close" do - before :each do - @socket = mock("Socket") - @socket.stub!(:closed?).and_return(false) - @socket.stub!(:read_timeout).and_return(60) - @socket.stub!(:read_timeout=).and_return(3) - - @ftp = Net::FTP.new - @ftp.instance_variable_set(:@sock, @socket) - end - - it "closes the socket" do - @socket.should_receive(:close) - @ftp.close.should be_nil - end - - it "does not try to close the socket if it has already been closed" do - @socket.should_receive(:closed?).and_return(true) - @socket.should_not_receive(:close) - @ftp.close.should be_nil - end - - it "does not try to close the socket if it is nil" do - @ftp.instance_variable_set(:@sock, nil) - @ftp.close.should be_nil - end - end -end diff --git a/spec/ruby/library/net/ftp/closed_spec.rb b/spec/ruby/library/net/ftp/closed_spec.rb deleted file mode 100644 index a81917090a..0000000000 --- a/spec/ruby/library/net/ftp/closed_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#closed?" do - before :each do - @socket = mock("Socket") - - @ftp = Net::FTP.new - @ftp.instance_variable_set(:@sock, @socket) - end - - it "returns true when the socket is closed" do - @socket.should_receive(:closed?).and_return(true) - @ftp.closed?.should be_true - end - - it "returns true when the socket is nil" do - @ftp.instance_variable_set(:@sock, nil) - @ftp.closed?.should be_true - end - end -end diff --git a/spec/ruby/library/net/ftp/connect_spec.rb b/spec/ruby/library/net/ftp/connect_spec.rb deleted file mode 100644 index b45e46c530..0000000000 --- a/spec/ruby/library/net/ftp/connect_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - # TODO: Add specs for using the SOCKSSocket - describe "Net::FTP#connect" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - end - - after :each do - @server.connect_message = nil - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "tries to connect to the FTP Server on the given host and port" do - -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error - end - - it "returns nil" do - @ftp.connect(@server.hostname, @server.server_port).should be_nil - end - - it "prints a small debug line when in debug mode" do - @ftp.debug_mode = true - -> { @ftp.connect(@server.hostname, @server.server_port) }.should output(/#{"connect: "}#{@server.hostname}#{", "}#{@server.server_port}#{"\\nget: 220 Dummy FTP Server ready!"}/) - @ftp.debug_mode = false - end - - it "does not raise any error when the response code is 220" do - @server.connect_message = "220 Dummy FTP Server ready!" - -> { @ftp.connect(@server.hostname, @server.server_port) }.should_not raise_error - end - - it "raises a Net::FTPReplyError when the response code is 120" do - @server.connect_message = "120 Service ready in nnn minutes." - -> { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPReplyError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.connect_message = "421 Service not available, closing control connection." - -> { @ftp.connect(@server.hostname, @server.server_port) }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/debug_mode_spec.rb b/spec/ruby/library/net/ftp/debug_mode_spec.rb deleted file mode 100644 index 46d207bbea..0000000000 --- a/spec/ruby/library/net/ftp/debug_mode_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#debug_mode" do - it "returns true when self is in debug mode" do - ftp = Net::FTP.new - ftp.debug_mode.should be_false - - ftp.debug_mode = true - ftp.debug_mode.should be_true - end - end - - describe "Net::FTP#debug_mode=" do - it "sets self into debug mode when passed true" do - ftp = Net::FTP.new - ftp.debug_mode = true - ftp.debug_mode.should be_true - - ftp.debug_mode = false - ftp.debug_mode.should be_false - end - end -end diff --git a/spec/ruby/library/net/ftp/default_passive_spec.rb b/spec/ruby/library/net/ftp/default_passive_spec.rb deleted file mode 100644 index 9348d3294d..0000000000 --- a/spec/ruby/library/net/ftp/default_passive_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#default_passive" do - it "is true by default" do - ruby_exe(fixture(__FILE__, "default_passive.rb")).should == "true\ntrue\n" - end - end -end diff --git a/spec/ruby/library/net/ftp/delete_spec.rb b/spec/ruby/library/net/ftp/delete_spec.rb deleted file mode 100644 index 43bfcc1541..0000000000 --- a/spec/ruby/library/net/ftp/delete_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#delete" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the DELE command with the passed filename to the server" do - @ftp.delete("test.file") - @ftp.last_response.should == "250 Requested file action okay, completed. (DELE test.file)\n" - end - - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:dele).and_respond("450 Requested file action not taken.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:dele).and_respond("550 Requested action not taken.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:dele).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:dele).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:dele).and_respond("502 Command not implemented.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:dele).and_respond("421 Service not available, closing control connection.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:dele).and_respond("530 Not logged in.") - -> { @ftp.delete("test.file") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/dir_spec.rb b/spec/ruby/library/net/ftp/dir_spec.rb deleted file mode 100644 index dce50a5ac5..0000000000 --- a/spec/ruby/library/net/ftp/dir_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/list' - - describe "Net::FTP#dir" do - it_behaves_like :net_ftp_list, :dir - end -end diff --git a/spec/ruby/library/net/ftp/fixtures/default_passive.rb b/spec/ruby/library/net/ftp/fixtures/default_passive.rb deleted file mode 100644 index b6995d6f34..0000000000 --- a/spec/ruby/library/net/ftp/fixtures/default_passive.rb +++ /dev/null @@ -1,3 +0,0 @@ -require "net/ftp" -puts Net::FTP.default_passive -puts Net::FTP.new.passive diff --git a/spec/ruby/library/net/ftp/fixtures/passive.rb b/spec/ruby/library/net/ftp/fixtures/passive.rb deleted file mode 100644 index 6b5cde82df..0000000000 --- a/spec/ruby/library/net/ftp/fixtures/passive.rb +++ /dev/null @@ -1,2 +0,0 @@ -require "net/ftp" -print Net::FTP.new.passive diff --git a/spec/ruby/library/net/ftp/fixtures/putbinaryfile b/spec/ruby/library/net/ftp/fixtures/putbinaryfile deleted file mode 100644 index f3130c6e43..0000000000 --- a/spec/ruby/library/net/ftp/fixtures/putbinaryfile +++ /dev/null @@ -1,3 +0,0 @@ -This is an example file -which is going to be transmitted -using #putbinaryfile. diff --git a/spec/ruby/library/net/ftp/fixtures/puttextfile b/spec/ruby/library/net/ftp/fixtures/puttextfile deleted file mode 100644 index b4f3b2b62d..0000000000 --- a/spec/ruby/library/net/ftp/fixtures/puttextfile +++ /dev/null @@ -1,3 +0,0 @@ -This is an example file -which is going to be transmitted -using #puttextfile. diff --git a/spec/ruby/library/net/ftp/fixtures/server.rb b/spec/ruby/library/net/ftp/fixtures/server.rb deleted file mode 100644 index ecbed591d5..0000000000 --- a/spec/ruby/library/net/ftp/fixtures/server.rb +++ /dev/null @@ -1,277 +0,0 @@ -module NetFTPSpecs - class DummyFTP - attr_accessor :connect_message - attr_reader :login_user, :login_pass, :login_acct - - # hostname or IP address - attr_reader :hostname - # port number - attr_reader :server_port - - def initialize - @hostname = "localhost" - @server = TCPServer.new(@hostname, 0) - @server_port = @server.addr[1] - - @handlers = {} - @commands = [] - @connect_message = nil - end - - def serve_once - @thread = Thread.new do - @socket = @server.accept - @socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_OOBINLINE, 1) - begin - handle_request - ensure - @socket.close - end - end - end - - def handle_request - # Send out the welcome message. - response @connect_message || "220 Dummy FTP Server ready!" - - begin - while command = @socket.gets - command, argument = command.chomp.split(" ", 2) - - if command == "QUIT" - self.response("221 OK, bye") - break - elsif proc_handler = @handlers[command.downcase.to_sym] - if argument.nil? - proc_handler.call(self) - else - proc_handler.call(self, argument) - end - else - if argument.nil? - self.send(command.downcase.to_sym) - else - self.send(command.downcase.to_sym, argument) - end - end - end - rescue => e - self.error_response("Exception: #{e} #{e.backtrace.inspect}") - end - end - - def error_response(text) - self.response("451 #{text}") - end - - def response(text) - @socket.puts(text) unless @socket.closed? - end - - def stop - @datasocket.close unless @datasocket.nil? || @datasocket.closed? - @server.close - @thread.join - end - - - ## - def handle(sym, &block) - @handlers[sym] = block - end - - def should_receive(method) - @handler_for = method - self - end - - def and_respond(text) - @handlers[@handler_for] = -> s, *args { s.response(text) } - end - - ## - # FTP methods - ## - - def abor - self.response("226 Closing data connection. (ABOR)") - end - - def acct(account) - @login_acct = account - self.response("230 User '#{account}' logged in, proceed. (ACCT)") - end - - def cdup - self.response("200 Command okay. (CDUP)") - end - - def cwd(dir) - self.response("200 Command okay. (CWD #{dir})") - end - - def dele(file) - self.response("250 Requested file action okay, completed. (DELE #{file})") - end - - def eprt(arg) - _, _, host, port = arg.split("|") - - @datasocket = TCPSocket.new(host, port) - self.response("200 port opened") - end - - def help(param = :default) - if param == :default - self.response("211 System status, or system help reply. (HELP)") - else - self.response("211 System status, or system help reply. (HELP #{param})") - end - end - - def list(folder) - self.response("150 opening ASCII connection for file list") - @datasocket.puts("-rw-r--r-- 1 spec staff 507 17 Jul 18:41 last_response_code.rb") - @datasocket.puts("-rw-r--r-- 1 spec staff 50 17 Jul 18:41 list.rb") - @datasocket.puts("-rw-r--r-- 1 spec staff 48 17 Jul 18:41 pwd.rb") - @datasocket.close() - self.response("226 transfer complete (LIST #{folder})") - end - - def mdtm(filename) - self.response("213 19980705132316") - end - - def mkd(foldername) - self.response(%Q{257 "#{foldername.gsub('"', '""')}" created.}) - end - - def nlst(folder = nil) - self.response("150 opening ASCII connection for file list") - @datasocket.puts("last_response_code.rb") - @datasocket.puts("list.rb") - @datasocket.puts("pwd.rb") - @datasocket.close() - self.response("226 transfer complete (NLST#{folder ? " #{folder}" : ""})") - end - - def noop - self.response("200 Command okay. (NOOP)") - end - - def pass(password) - @login_pass = password - self.response("230 User logged in, proceed. (PASS #{password})") - end - - def port(arg) - nums = arg.split(",") - - if nums[0] == "::1" - # IPv6 - port = nums[1].to_i * 256 + nums[2].to_i - host = nums[0] - else - # IPv4 - port = nums[4].to_i * 256 + nums[5].to_i - host = nums[0..3].join(".") - end - - @datasocket = TCPSocket.new(host, port) - self.response("200 port opened") - end - - def pwd - self.response('257 "/some/dir/" - current directory') - end - - def retr(file) - self.response("125 Data transfer starting") - if @restart_at && @restart_at == 20 - @datasocket.puts("of the file named '#{file}'.") - @restart_at = nil - else - @datasocket.puts("This is the content") - @datasocket.puts("of the file named '#{file}'.") - end - @datasocket.close() - self.response("226 Closing data connection. (RETR #{file})") - end - - def rest(at_bytes) - @restart_at = at_bytes.to_i - self.response("350 Requested file action pending further information. (REST)") - end - - def rmd(folder) - self.response("250 Requested file action okay, completed. (RMD #{folder})") - end - - def rnfr(from) - @rename_from = from - self.response("350 Requested file action pending further information.") - end - - def rnto(to) - self.response("250 Requested file action okay, completed. (Renamed #{@rename_from} to #{to})") - @rename_from = nil - end - - def site(param) - self.response("200 Command okay. (SITE #{param})") - end - - def size(filename) - if filename == "binary" - self.response("213 24") - else - self.response("213 1024") - end - end - - 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) - tmp_file = tmp("#{file}file", false) - - self.response("125 Data transfer starting.") - - mode = @restart_at ? "a" : "w" - - File.open(tmp_file, mode + "b") do |f| - loop do - data = @datasocket.recv(1024) - break if !data || data.empty? - f << data - end - end - - @datasocket.close() - self.response("200 OK, Data received. (STOR #{file})") - end - - def appe(file) - @restart_at = true - stor(file) - end - - def syst - self.response("215 FTP Dummy Server (SYST)") - end - - def type(type) - self.response("200 TYPE switched to #{type}") - end - - def user(name) - @login_user = name - self.response("230 User logged in, proceed. (USER #{name})") - end - end -end diff --git a/spec/ruby/library/net/ftp/get_spec.rb b/spec/ruby/library/net/ftp/get_spec.rb deleted file mode 100644 index 892b30061c..0000000000 --- a/spec/ruby/library/net/ftp/get_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/gettextfile' - require_relative 'shared/getbinaryfile' - - describe "Net::FTP#get (binary mode)" do - before :each do - @binary_mode = true - end - - it_behaves_like :net_ftp_getbinaryfile, :get - end - - describe "Net::FTP#get (text mode)" do - before :each do - @binary_mode = false - end - - it_behaves_like :net_ftp_gettextfile, :get - end -end diff --git a/spec/ruby/library/net/ftp/getbinaryfile_spec.rb b/spec/ruby/library/net/ftp/getbinaryfile_spec.rb deleted file mode 100644 index c5abdd67e7..0000000000 --- a/spec/ruby/library/net/ftp/getbinaryfile_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/getbinaryfile' - - describe "Net::FTP#getbinaryfile" do - it_behaves_like :net_ftp_getbinaryfile, :getbinaryfile - end -end diff --git a/spec/ruby/library/net/ftp/getdir_spec.rb b/spec/ruby/library/net/ftp/getdir_spec.rb deleted file mode 100644 index 8f6fca5bfb..0000000000 --- a/spec/ruby/library/net/ftp/getdir_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'shared/pwd' - - describe "Net::FTP#getdir" do - it_behaves_like :net_ftp_pwd, :getdir - end -end diff --git a/spec/ruby/library/net/ftp/gettextfile_spec.rb b/spec/ruby/library/net/ftp/gettextfile_spec.rb deleted file mode 100644 index e272ae73b1..0000000000 --- a/spec/ruby/library/net/ftp/gettextfile_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/gettextfile' - - describe "Net::FTP#gettextfile" do - it_behaves_like :net_ftp_gettextfile, :gettextfile - end -end diff --git a/spec/ruby/library/net/ftp/help_spec.rb b/spec/ruby/library/net/ftp/help_spec.rb deleted file mode 100644 index 9b15f42ede..0000000000 --- a/spec/ruby/library/net/ftp/help_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#help" do - def with_connection - yield - end - - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "writes the HELP command to the server" do - @ftp.help - @ftp.last_response.should == "211 System status, or system help reply. (HELP)\n" - end - - it "returns the server's response" do - @ftp.help.should == "211 System status, or system help reply. (HELP)\n" - end - - it "writes the HELP command with an optional parameter to the socket" do - @ftp.help("some parameter").should == "211 System status, or system help reply. (HELP some parameter)\n" - end - - it "does not raise any error when the response code is 211" do - @server.should_receive(:help).and_respond("211 System status, or system help reply.") - -> { @ftp.help }.should_not raise_error - end - - it "does not raise any error when the response code is 214" do - @server.should_receive(:help).and_respond("214 Help message.") - -> { @ftp.help }.should_not raise_error - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:help).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.help }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:help).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.help }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:help).and_respond("502 Command not implemented.") - -> { @ftp.help }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:help).and_respond("421 Service not available, closing control connection.") - -> { @ftp.help }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/initialize_spec.rb b/spec/ruby/library/net/ftp/initialize_spec.rb deleted file mode 100644 index 80f71a9161..0000000000 --- a/spec/ruby/library/net/ftp/initialize_spec.rb +++ /dev/null @@ -1,408 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#initialize" do - before :each do - @ftp = Net::FTP.allocate - @ftp.stub!(:connect) - @port_args = [] - @port_args << 21 - end - - it "is private" do - Net::FTP.should have_private_instance_method(:initialize) - end - - it "sets self into binary mode" do - @ftp.binary.should be_nil - @ftp.send(:initialize) - @ftp.binary.should be_true - end - - it "sets self into active mode" do - @ftp.passive.should be_nil - @ftp.send(:initialize) - @ftp.passive.should be_false - end - - it "sets self into non-debug mode" do - @ftp.debug_mode.should be_nil - @ftp.send(:initialize) - @ftp.debug_mode.should be_false - end - - it "sets self to not resume file uploads/downloads" do - @ftp.resume.should be_nil - @ftp.send(:initialize) - @ftp.resume.should be_false - end - - describe "when passed no arguments" do - it "does not try to connect" do - @ftp.should_not_receive(:connect) - @ftp.send(:initialize) - end - end - - describe "when passed host" do - it "tries to connect to the passed host" do - @ftp.should_receive(:connect).with("localhost", *@port_args) - @ftp.send(:initialize, "localhost") - end - end - - describe "when passed host, user" do - it "tries to connect to the passed host" do - @ftp.should_receive(:connect).with("localhost", *@port_args) - @ftp.send(:initialize, "localhost") - end - - it "tries to login with the passed username" do - @ftp.should_receive(:login).with("rubyspec", nil, nil) - @ftp.send(:initialize, "localhost", "rubyspec") - end - end - - describe "when passed host, user, password" do - it "tries to connect to the passed host" do - @ftp.should_receive(:connect).with("localhost", *@port_args) - @ftp.send(:initialize, "localhost") - end - - it "tries to login with the passed username and password" do - @ftp.should_receive(:login).with("rubyspec", "rocks", nil) - @ftp.send(:initialize, "localhost", "rubyspec", "rocks") - end - end - - describe "when passed host, user" do - it "tries to connect to the passed host" do - @ftp.should_receive(:connect).with("localhost", *@port_args) - @ftp.send(:initialize, "localhost") - end - - it "tries to login with the passed username, password and account" do - @ftp.should_receive(:login).with("rubyspec", "rocks", "account") - @ftp.send(:initialize, "localhost", "rubyspec", "rocks", "account") - end - end - - before :each do - @ftp.stub!(:login) - end - - describe 'when the host' do - describe 'is set' do - describe 'and port option' do - describe 'is set' do - it 'tries to connect to the host on the specified port' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ port: 8080 }) - @ftp.should_receive(:connect).with('localhost', 8080) - - @ftp.send(:initialize, 'localhost', options) - end - end - - describe 'is not set' do - it 'tries to connect to the host without a port' do - @ftp.should_receive(:connect).with("localhost", *@port_args) - - @ftp.send(:initialize, 'localhost') - end - end - end - - describe 'when the username option' do - describe 'is set' do - describe 'and the password option' do - describe 'is set' do - describe 'and the account option' do - describe 'is set' do - it 'tries to log in with the supplied parameters' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret', account: 'b' }) - @ftp.should_receive(:login).with('a', 'topsecret', 'b') - - @ftp.send(:initialize, 'localhost', options) - end - end - - describe 'is unset' do - it 'tries to log in with the supplied parameters' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ username: 'a', password: 'topsecret' }) - @ftp.should_receive(:login).with('a', 'topsecret', nil) - - @ftp.send(:initialize, 'localhost', options) - end - end - end - end - - describe 'is unset' do - describe 'and the account option' do - describe 'is set' do - it 'tries to log in with the supplied parameters' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ username: 'a', account: 'b' }) - @ftp.should_receive(:login).with('a', nil, 'b') - - @ftp.send(:initialize, 'localhost', options) - end - end - - describe 'is unset' do - it 'tries to log in with the supplied parameters' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ username: 'a'}) - @ftp.should_receive(:login).with('a', nil, nil) - - @ftp.send(:initialize, 'localhost', options) - end - end - end - end - end - end - - describe 'is not set' do - it 'does not try to log in' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({}) - @ftp.should_not_receive(:login) - - @ftp.send(:initialize, 'localhost', options) - end - end - end - end - - describe 'is unset' do - it 'does not try to connect' do - @ftp.should_not_receive(:connect) - - @ftp.send(:initialize) - end - - it 'does not try to log in' do - @ftp.should_not_receive(:login) - - @ftp.send(:initialize) - end - end - end - - describe 'when the passive option' do - describe 'is set' do - describe 'to true' do - it 'sets passive to true' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ passive: true }) - - @ftp.send(:initialize, nil, options) - @ftp.passive.should == true - end - end - - describe 'to false' do - it 'sets passive to false' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ passive: false }) - - @ftp.send(:initialize, nil, options) - @ftp.passive.should == false - end - end - end - - describe 'is unset' do - it 'sets passive to false' do - @ftp.send(:initialize) - @ftp.passive.should == false - end - end - end - - describe 'when the debug_mode option' do - describe 'is set' do - describe 'to true' do - it 'sets debug_mode to true' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ debug_mode: true }) - - @ftp.send(:initialize, nil, options) - @ftp.debug_mode.should == true - end - end - - describe 'to false' do - it 'sets debug_mode to false' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ debug_mode: false }) - - @ftp.send(:initialize, nil, options) - @ftp.debug_mode.should == false - end - end - end - - describe 'is unset' do - it 'sets debug_mode to false' do - @ftp.send(:initialize) - @ftp.debug_mode.should == false - end - end - end - - describe 'when the open_timeout option' do - describe 'is set' do - it 'sets open_timeout to the specified value' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ open_timeout: 42 }) - - @ftp.send(:initialize, nil, options) - @ftp.open_timeout.should == 42 - end - end - - describe 'is not set' do - it 'sets open_timeout to nil' do - @ftp.send(:initialize) - @ftp.open_timeout.should == nil - end - end - end - - describe 'when the read_timeout option' do - describe 'is set' do - it 'sets read_timeout to the specified value' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ read_timeout: 100 }) - - @ftp.send(:initialize, nil, options) - @ftp.read_timeout.should == 100 - end - end - - describe 'is not set' do - it 'sets read_timeout to the default value' do - @ftp.send(:initialize) - @ftp.read_timeout.should == 60 - end - end - end - - describe 'when the ssl_handshake_timeout option' do - describe 'is set' do - it 'sets ssl_handshake_timeout to the specified value' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ ssl_handshake_timeout: 23 }) - - @ftp.send(:initialize, nil, options) - @ftp.ssl_handshake_timeout.should == 23 - end - end - - describe 'is not set' do - it 'sets ssl_handshake_timeout to nil' do - @ftp.send(:initialize) - @ftp.ssl_handshake_timeout.should == nil - end - end - end - - describe 'when the ssl option' do - describe 'is set' do - describe "and the ssl option's value is true" do - it 'initializes ssl_context to a blank SSLContext object' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ ssl: true }) - - ssl_context = OpenSSL::SSL::SSLContext.allocate - ssl_context.stub!(:set_params) - - OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context) - ssl_context.should_receive(:set_params).with({}) - - @ftp.send(:initialize, nil, options) - @ftp.instance_variable_get(:@ssl_context).should == ssl_context - end - end - - describe "and the ssl option's value is a hash" do - it 'initializes ssl_context to a configured SSLContext object' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ ssl: {key: 'value'} }) - - ssl_context = OpenSSL::SSL::SSLContext.allocate - ssl_context.stub!(:set_params) - - OpenSSL::SSL::SSLContext.should_receive(:new).and_return(ssl_context) - ssl_context.should_receive(:set_params).with({key: 'value'}) - - @ftp.send(:initialize, nil, options) - @ftp.instance_variable_get(:@ssl_context).should == ssl_context - end - end - - describe 'and private_data_connection' do - describe 'is set' do - it 'sets private_data_connection to that value' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ ssl: true, private_data_connection: 'true' }) - - @ftp.send(:initialize, nil, options) - @ftp.instance_variable_get(:@private_data_connection).should == 'true' - end - end - - describe 'is not set' do - it 'sets private_data_connection to nil' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ ssl: true }) - - @ftp.send(:initialize, nil, options) - @ftp.instance_variable_get(:@private_data_connection).should == true - end - end - end - end - - describe 'is not set' do - it 'sets ssl_context to nil' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({}) - - @ftp.send(:initialize, nil, options) - @ftp.instance_variable_get(:@ssl_context).should == nil - end - - describe 'private_data_connection' do - describe 'is set' do - it 'raises an ArgumentError' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({ private_data_connection: true }) - - -> { - @ftp.send(:initialize, nil, options) - }.should raise_error(ArgumentError, /private_data_connection can be set to true only when ssl is enabled/) - end - end - - describe 'is not set' do - it 'sets private_data_connection to false' do - options = mock('ftp initialize options') - options.should_receive(:to_hash).and_return({}) - - @ftp.send(:initialize, nil, options) - @ftp.instance_variable_get(:@private_data_connection).should == false - end - end - end - end - end - end -end diff --git a/spec/ruby/library/net/ftp/last_response_code_spec.rb b/spec/ruby/library/net/ftp/last_response_code_spec.rb deleted file mode 100644 index 86f2b9a695..0000000000 --- a/spec/ruby/library/net/ftp/last_response_code_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'shared/last_response_code' - require_relative 'fixtures/server' - - describe "Net::FTP#last_response_code" do - it_behaves_like :net_ftp_last_response_code, :last_response_code - end -end diff --git a/spec/ruby/library/net/ftp/last_response_spec.rb b/spec/ruby/library/net/ftp/last_response_spec.rb deleted file mode 100644 index 1d29b9b73f..0000000000 --- a/spec/ruby/library/net/ftp/last_response_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#last_response" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "returns the last response" do - @ftp.last_response.should == "220 Dummy FTP Server ready!\n" - @ftp.help - @ftp.last_response.should == "211 System status, or system help reply. (HELP)\n" - end - end -end diff --git a/spec/ruby/library/net/ftp/lastresp_spec.rb b/spec/ruby/library/net/ftp/lastresp_spec.rb deleted file mode 100644 index 9d26efb8f8..0000000000 --- a/spec/ruby/library/net/ftp/lastresp_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'shared/last_response_code' - require_relative 'fixtures/server' - - describe "Net::FTP#lastresp" do - it_behaves_like :net_ftp_last_response_code, :lastresp - end -end diff --git a/spec/ruby/library/net/ftp/list_spec.rb b/spec/ruby/library/net/ftp/list_spec.rb deleted file mode 100644 index 6cffafeb4f..0000000000 --- a/spec/ruby/library/net/ftp/list_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/list' - - describe "Net::FTP#list" do - it_behaves_like :net_ftp_list, :list - end -end diff --git a/spec/ruby/library/net/ftp/login_spec.rb b/spec/ruby/library/net/ftp/login_spec.rb deleted file mode 100644 index 981b439082..0000000000 --- a/spec/ruby/library/net/ftp/login_spec.rb +++ /dev/null @@ -1,198 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#login" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - describe "when passed no arguments" do - it "sends the USER command with 'anonymous' as name to the server" do - @ftp.login - @server.login_user.should == "anonymous" - end - - it "sends 'anonymous@' as a password when required" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @ftp.login - @server.login_pass.should == "anonymous@" - end - - it "raises a Net::FTPReplyError when the server requests an account" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @server.should_receive(:pass).and_respond("332 Need account for login.") - -> { @ftp.login }.should raise_error(Net::FTPReplyError) - end - end - - describe "when passed name" do - it "sends the USER command with the passed name to the server" do - @ftp.login("rubyspec") - @server.login_user.should == "rubyspec" - end - - it "raises a Net::FTPReplyError when the server requests a password, but none was given" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - -> { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError) - end - - it "raises a Net::FTPReplyError when the server requests an account, but none was given" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @server.should_receive(:pass).and_respond("332 Need account for login.") - -> { @ftp.login("rubyspec") }.should raise_error(Net::FTPReplyError) - end - end - - describe "when passed name, password" do - it "sends the USER command with the passed name to the server" do - @ftp.login("rubyspec", "rocks") - @server.login_user.should == "rubyspec" - end - - it "sends the passed password when required" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @ftp.login("rubyspec", "rocks") - @server.login_pass.should == "rocks" - end - - it "raises a Net::FTPReplyError when the server requests an account" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @server.should_receive(:pass).and_respond("332 Need account for login.") - -> { @ftp.login("rubyspec", "rocks") }.should raise_error(Net::FTPReplyError) - end - end - - describe "when passed name, password, account" do - it "sends the USER command with the passed name to the server" do - @ftp.login("rubyspec", "rocks", "account") - @server.login_user.should == "rubyspec" - end - - it "sends the passed password when required" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @ftp.login("rubyspec", "rocks", "account") - @server.login_pass.should == "rocks" - end - - it "sends the passed account when required" do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @server.should_receive(:pass).and_respond("332 Need account for login.") - @ftp.login("rubyspec", "rocks", "account") - @server.login_acct.should == "account" - end - end - - describe "when the USER command fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:user).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:user).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:user).and_respond("502 Command not implemented.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:user).and_respond("421 Service not available, closing control connection.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:user).and_respond("530 Not logged in.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - end - - describe "when the PASS command fails" do - before :each do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - end - - it "does not raise an Error when the response code is 202" do - @server.should_receive(:pass).and_respond("202 Command not implemented, superfluous at this site.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:pass).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:pass).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:pass).and_respond("502 Command not implemented.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:pass).and_respond("421 Service not available, closing control connection.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:pass).and_respond("530 Not logged in.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - end - - describe "when the ACCT command fails" do - before :each do - @server.should_receive(:user).and_respond("331 User name okay, need password.") - @server.should_receive(:pass).and_respond("332 Need account for login.") - end - - it "does not raise an Error when the response code is 202" do - @server.should_receive(:acct).and_respond("202 Command not implemented, superfluous at this site.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should_not raise_error - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:acct).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:acct).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:acct).and_respond("502 Command not implemented.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:acct).and_respond("421 Service not available, closing control connection.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:acct).and_respond("530 Not logged in.") - -> { @ftp.login("rubyspec", "rocks", "account") }.should raise_error(Net::FTPPermError) - end - end - end -end diff --git a/spec/ruby/library/net/ftp/ls_spec.rb b/spec/ruby/library/net/ftp/ls_spec.rb deleted file mode 100644 index f262515865..0000000000 --- a/spec/ruby/library/net/ftp/ls_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/list' - - describe "Net::FTP#ls" do - it_behaves_like :net_ftp_list, :ls - end -end diff --git a/spec/ruby/library/net/ftp/mdtm_spec.rb b/spec/ruby/library/net/ftp/mdtm_spec.rb deleted file mode 100644 index ea55533c43..0000000000 --- a/spec/ruby/library/net/ftp/mdtm_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#mdtm" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the MDTM with the passed filename command to the server" do - @ftp.mdtm("test.file") - @ftp.last_response.should == "213 19980705132316\n" - end - - it "returns the last modification time of the passed file" do - @ftp.mdtm("test.file").should == "19980705132316" - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:mdtm).and_respond("550 Requested action not taken.") - -> { @ftp.mdtm("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.") - -> { @ftp.mdtm("test.file") }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/mkdir_spec.rb b/spec/ruby/library/net/ftp/mkdir_spec.rb deleted file mode 100644 index 2cb437a076..0000000000 --- a/spec/ruby/library/net/ftp/mkdir_spec.rb +++ /dev/null @@ -1,64 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#mkdir" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the MKD command with the passed pathname to the server" do - @ftp.mkdir("test.folder") - @ftp.last_response.should == %{257 "test.folder" created.\n} - end - - it "returns the path to the newly created directory" do - @ftp.mkdir("test.folder").should == "test.folder" - @ftp.mkdir("/absolute/path/to/test.folder").should == "/absolute/path/to/test.folder" - @ftp.mkdir("relative/path/to/test.folder").should == "relative/path/to/test.folder" - @ftp.mkdir('/usr/dm/foo"bar').should == '/usr/dm/foo"bar' - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:mkd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:mkd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:mkd).and_respond("502 Command not implemented.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:mkd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:mkd).and_respond("530 Not logged in.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:mkd).and_respond("550 Requested action not taken.") - -> { @ftp.mkdir("test.folder") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/mtime_spec.rb b/spec/ruby/library/net/ftp/mtime_spec.rb deleted file mode 100644 index 7265667a52..0000000000 --- a/spec/ruby/library/net/ftp/mtime_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#mtime" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the MDTM with the passed filename command to the server" do - @ftp.mtime("test.file") - @ftp.last_response.should == "213 19980705132316\n" - end - - describe "when passed filename" do - it "returns the last modification time of the passed file as a Time object in the local time" do - @ftp.mtime("test.file").should == Time.gm("1998", "07", "05", "13", "23", "16") - end - end - - describe "when passed filename, local_time" do - it "returns the last modification time as a Time object in UTC when local_time is true" do - @ftp.mtime("test.file", true).should == Time.local("1998", "07", "05", "13", "23", "16") - end - - it "returns the last modification time as a Time object in the local time when local_time is false" do - @ftp.mtime("test.file", false).should == Time.gm("1998", "07", "05", "13", "23", "16") - end - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:mdtm).and_respond("550 Requested action not taken.") - -> { @ftp.mtime("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.") - -> { @ftp.mtime("test.file") }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/nlst_spec.rb b/spec/ruby/library/net/ftp/nlst_spec.rb deleted file mode 100644 index 0de84b3a76..0000000000 --- a/spec/ruby/library/net/ftp/nlst_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#nlst" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.passive = false - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - describe "when passed no arguments" do - it "returns an Array containing a list of files in the current dir" do - @ftp.nlst.should == ["last_response_code.rb", "list.rb", "pwd.rb"] - @ftp.last_response.should == "226 transfer complete (NLST)\n" - end - end - - describe "when passed dir" do - it "returns an Array containing a list of files in the passed dir" do - @ftp.nlst("test.folder").should == ["last_response_code.rb", "list.rb", "pwd.rb"] - @ftp.last_response.should == "226 transfer complete (NLST test.folder)\n" - end - end - - describe "when the NLST command fails" do - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:nlst).and_respond("450 Requested file action not taken..") - -> { @ftp.nlst }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:nlst).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:nlst).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:nlst).and_respond("502 Command not implemented.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:nlst).and_respond("421 Service not available, closing control connection.") - -> { @ftp.nlst }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:nlst).and_respond("530 Not logged in.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - end - - describe "when opening the data port fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") - @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") - @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") - @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.nlst }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:eprt).and_respond("530 Not logged in.") - @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.nlst }.should raise_error(Net::FTPPermError) - end - end - end -end diff --git a/spec/ruby/library/net/ftp/noop_spec.rb b/spec/ruby/library/net/ftp/noop_spec.rb deleted file mode 100644 index 71011d4af7..0000000000 --- a/spec/ruby/library/net/ftp/noop_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#noop" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the NOOP command to the server" do - @ftp.noop - @ftp.last_response.should == "200 Command okay. (NOOP)\n" - end - - it "returns nil" do - @ftp.noop.should be_nil - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:noop).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.noop }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:noop).and_respond("421 Service not available, closing control connection.") - -> { @ftp.noop }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/open_spec.rb b/spec/ruby/library/net/ftp/open_spec.rb deleted file mode 100644 index 89187b9802..0000000000 --- a/spec/ruby/library/net/ftp/open_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP.open" do - before :each do - @ftp = mock("Net::FTP instance") - Net::FTP.stub!(:new).and_return(@ftp) - end - - describe "when passed no block" do - it "returns a new Net::FTP instance" do - Net::FTP.open("localhost").should equal(@ftp) - end - - it "passes the passed arguments down to Net::FTP.new" do - Net::FTP.should_receive(:new).with("localhost", "user", "password", "account") - Net::FTP.open("localhost", "user", "password", "account") - end - end - - describe "when passed a block" do - before :each do - @ftp.stub!(:close) - end - - it "yields a new Net::FTP instance to the passed block" do - yielded = false - Net::FTP.open("localhost") do |ftp| - yielded = true - ftp.should equal(@ftp) - end - yielded.should be_true - end - - it "closes the Net::FTP instance after yielding" do - Net::FTP.open("localhost") do |ftp| - ftp.should_receive(:close) - end - end - - it "closes the Net::FTP instance even if an exception is raised while yielding" do - begin - Net::FTP.open("localhost") do |ftp| - ftp.should_receive(:close) - raise ArgumentError, "some exception" - end - rescue ArgumentError - end - end - - it "returns the block's return value" do - Net::FTP.open("localhost") { :test }.should == :test - end - end - end -end diff --git a/spec/ruby/library/net/ftp/passive_spec.rb b/spec/ruby/library/net/ftp/passive_spec.rb deleted file mode 100644 index f9c34efb7d..0000000000 --- a/spec/ruby/library/net/ftp/passive_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#passive" do - it "returns true when self is in passive mode" do - ftp = Net::FTP.new - ftp.passive.should be_false - - ftp.passive = true - ftp.passive.should be_true - end - - it "is the value of Net::FTP.default_value by default" do - ruby_exe(fixture(__FILE__, "passive.rb")).should == "true" - end - end - - describe "Net::FTP#passive=" do - it "sets self to passive mode when passed true" do - ftp = Net::FTP.new - - ftp.passive = true - ftp.passive.should be_true - - ftp.passive = false - ftp.passive.should be_false - end - end -end diff --git a/spec/ruby/library/net/ftp/put_spec.rb b/spec/ruby/library/net/ftp/put_spec.rb deleted file mode 100644 index 36ba6c1963..0000000000 --- a/spec/ruby/library/net/ftp/put_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/puttextfile' - require_relative 'shared/putbinaryfile' - - describe "Net::FTP#put (binary mode)" do - before :each do - @binary_mode = true - end - - it_behaves_like :net_ftp_putbinaryfile, :put - end - - describe "Net::FTP#put (text mode)" do - before :each do - @binary_mode = false - end - - it_behaves_like :net_ftp_puttextfile, :put - end -end diff --git a/spec/ruby/library/net/ftp/putbinaryfile_spec.rb b/spec/ruby/library/net/ftp/putbinaryfile_spec.rb deleted file mode 100644 index 6ced5246fe..0000000000 --- a/spec/ruby/library/net/ftp/putbinaryfile_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/putbinaryfile' - - describe "Net::FTP#putbinaryfile" do - it_behaves_like :net_ftp_putbinaryfile, :putbinaryfile - end -end diff --git a/spec/ruby/library/net/ftp/puttextfile_spec.rb b/spec/ruby/library/net/ftp/puttextfile_spec.rb deleted file mode 100644 index 0cab6bd3c3..0000000000 --- a/spec/ruby/library/net/ftp/puttextfile_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - require_relative 'shared/puttextfile' - - describe "Net::FTP#puttextfile" do - it_behaves_like :net_ftp_puttextfile, :puttextfile - end -end diff --git a/spec/ruby/library/net/ftp/pwd_spec.rb b/spec/ruby/library/net/ftp/pwd_spec.rb deleted file mode 100644 index 856ff5ff9b..0000000000 --- a/spec/ruby/library/net/ftp/pwd_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#pwd" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the PWD command to the server" do - @ftp.pwd - @ftp.last_response.should == "257 \"/some/dir/\" - current directory\n" - end - - it "returns the current directory" do - @ftp.pwd.should == "/some/dir/" - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:pwd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:pwd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:pwd).and_respond("502 Command not implemented.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:pwd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.pwd }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:pwd).and_respond("550 Requested action not taken.") - -> { @ftp.pwd }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/quit_spec.rb b/spec/ruby/library/net/ftp/quit_spec.rb deleted file mode 100644 index 12b9fd3cee..0000000000 --- a/spec/ruby/library/net/ftp/quit_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#quit" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the QUIT command to the server" do - @ftp.quit - @ftp.last_response.should == "221 OK, bye\n" - end - - it "does not close the socket automatically" do - @ftp.quit - @ftp.closed?.should be_false - end - - it "returns nil" do - @ftp.quit.should be_nil - end - end -end diff --git a/spec/ruby/library/net/ftp/rename_spec.rb b/spec/ruby/library/net/ftp/rename_spec.rb deleted file mode 100644 index aa7c1360b5..0000000000 --- a/spec/ruby/library/net/ftp/rename_spec.rb +++ /dev/null @@ -1,97 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#rename" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - describe "when passed from_name, to_name" do - it "sends the RNFR command with the passed from_name and the RNTO command with the passed to_name to the server" do - @ftp.rename("from.file", "to.file") - @ftp.last_response.should == "250 Requested file action okay, completed. (Renamed from.file to to.file)\n" - end - - it "returns something" do - @ftp.rename("from.file", "to.file").should be_nil - end - end - - describe "when the RNFR command fails" do - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:rnfr).and_respond("450 Requested file action not taken.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:rnfr).and_respond("550 Requested action not taken.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:rnfr).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:rnfr).and_respond("502 Command not implemented.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:rnfr).and_respond("421 Service not available, closing control connection.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:rnfr).and_respond("530 Not logged in.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - end - - describe "when the RNTO command fails" do - it "raises a Net::FTPPermError when the response code is 532" do - @server.should_receive(:rnfr).and_respond("532 Need account for storing files.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 553" do - @server.should_receive(:rnto).and_respond("553 Requested action not taken.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:rnto).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:rnto).and_respond("502 Command not implemented.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:rnto).and_respond("421 Service not available, closing control connection.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:rnto).and_respond("530 Not logged in.") - -> { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError) - end - end - end -end diff --git a/spec/ruby/library/net/ftp/resume_spec.rb b/spec/ruby/library/net/ftp/resume_spec.rb deleted file mode 100644 index 1b575c29f1..0000000000 --- a/spec/ruby/library/net/ftp/resume_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#resume" do - it "returns true when self is set to resume uploads/downloads" do - ftp = Net::FTP.new - ftp.resume.should be_false - - ftp.resume = true - ftp.resume.should be_true - end - end - - describe "Net::FTP#resume=" do - it "sets self to resume uploads/downloads when set to true" do - ftp = Net::FTP.new - ftp.resume = true - ftp.resume.should be_true - - ftp.resume = false - ftp.resume.should be_false - end - end -end diff --git a/spec/ruby/library/net/ftp/retrbinary_spec.rb b/spec/ruby/library/net/ftp/retrbinary_spec.rb deleted file mode 100644 index 1f89f0d454..0000000000 --- a/spec/ruby/library/net/ftp/retrbinary_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#retrbinary" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the passed command to the server" do - @ftp.retrbinary("RETR test", 4096) {} - @ftp.last_response.should == "226 Closing data connection. (RETR test)\n" - end - - it "yields the received content as binary blocks of the passed size" do - res = [] - @ftp.retrbinary("RETR test", 10) { |bin| res << bin } - res.should == [ "This is th", "e content\n", "of the fil", "e named 't", "est'.\n" ] - end - end -end diff --git a/spec/ruby/library/net/ftp/retrlines_spec.rb b/spec/ruby/library/net/ftp/retrlines_spec.rb deleted file mode 100644 index f26b008680..0000000000 --- a/spec/ruby/library/net/ftp/retrlines_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#retrlines" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the passed command over the socket" do - @ftp.retrlines("LIST test.dir") {} - @ftp.last_response.should == "226 transfer complete (LIST test.dir)\n" - end - - it "yields each received line to the passed block" do - res = [] - @ftp.retrlines("LIST test.dir") { |x| res << x } - res.should == [ - "-rw-r--r-- 1 spec staff 507 17 Jul 18:41 last_response_code.rb", - "-rw-r--r-- 1 spec staff 50 17 Jul 18:41 list.rb", - "-rw-r--r-- 1 spec staff 48 17 Jul 18:41 pwd.rb" - ] - end - end -end diff --git a/spec/ruby/library/net/ftp/return_code_spec.rb b/spec/ruby/library/net/ftp/return_code_spec.rb deleted file mode 100644 index 67fc9d3b19..0000000000 --- a/spec/ruby/library/net/ftp/return_code_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#return_code" do - before :each do - @ftp = Net::FTP.new - end - - it "outputs a warning and returns a newline" do - -> do - @ftp.return_code.should == "\n" - end.should complain(/warning: Net::FTP#return_code is obsolete and do nothing/) - end - end - - describe "Net::FTP#return_code=" do - before :each do - @ftp = Net::FTP.new - end - - it "outputs a warning" do - -> { @ftp.return_code = 123 }.should complain(/warning: Net::FTP#return_code= is obsolete and do nothing/) - end - end -end diff --git a/spec/ruby/library/net/ftp/rmdir_spec.rb b/spec/ruby/library/net/ftp/rmdir_spec.rb deleted file mode 100644 index 5b9586c6f0..0000000000 --- a/spec/ruby/library/net/ftp/rmdir_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#rmdir" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the RMD command with the passed pathname to the server" do - @ftp.rmdir("test.folder") - @ftp.last_response.should == "250 Requested file action okay, completed. (RMD test.folder)\n" - end - - it "returns nil" do - @ftp.rmdir("test.folder").should be_nil - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:rmd).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:rmd).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:rmd).and_respond("502 Command not implemented.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:rmd).and_respond("421 Service not available, closing control connection.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:rmd).and_respond("530 Not logged in.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:rmd).and_respond("550 Requested action not taken.") - -> { @ftp.rmdir("test.folder") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/sendcmd_spec.rb b/spec/ruby/library/net/ftp/sendcmd_spec.rb deleted file mode 100644 index fefb89ae0b..0000000000 --- a/spec/ruby/library/net/ftp/sendcmd_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#sendcmd" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the passed command to the server" do - @ftp.sendcmd("HELP") - @ftp.last_response.should == "211 System status, or system help reply. (HELP)\n" - end - - it "returns the server's response" do - @ftp.sendcmd("HELP").should == "211 System status, or system help reply. (HELP)\n" - end - - it "raises no error when the response code is 1xx, 2xx or 3xx" do - @server.should_receive(:help).and_respond("120 Service ready in nnn minutes.") - -> { @ftp.sendcmd("HELP") }.should_not raise_error - - @server.should_receive(:help).and_respond("200 Command okay.") - -> { @ftp.sendcmd("HELP") }.should_not raise_error - - @server.should_receive(:help).and_respond("350 Requested file action pending further information.") - -> { @ftp.sendcmd("HELP") }.should_not raise_error - end - - it "raises a Net::FTPTempError when the response code is 4xx" do - @server.should_receive(:help).and_respond("421 Service not available, closing control connection.") - -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 5xx" do - @server.should_receive(:help).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPProtoError when the response code is not between 1xx-5xx" do - @server.should_receive(:help).and_respond("999 Invalid response.") - -> { @ftp.sendcmd("HELP") }.should raise_error(Net::FTPProtoError) - end - end -end diff --git a/spec/ruby/library/net/ftp/set_socket_spec.rb b/spec/ruby/library/net/ftp/set_socket_spec.rb deleted file mode 100644 index 6c8b58fb79..0000000000 --- a/spec/ruby/library/net/ftp/set_socket_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - - describe "Net::FTP#set_socket" do - # TODO: I won't spec this method, as it is not used - # anywhere and it should be private anyway. - it "needs to be reviewed for spec completeness" - end -end diff --git a/spec/ruby/library/net/ftp/shared/getbinaryfile.rb b/spec/ruby/library/net/ftp/shared/getbinaryfile.rb deleted file mode 100644 index f324f5b85d..0000000000 --- a/spec/ruby/library/net/ftp/shared/getbinaryfile.rb +++ /dev/null @@ -1,150 +0,0 @@ -describe :net_ftp_getbinaryfile, shared: :true do - before :each do - @fixture_file = File.dirname(__FILE__) + "/../fixtures/getbinaryfile" - @tmp_file = tmp("getbinaryfile") - - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - @ftp.binary = @binary_mode - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - - rm_r @tmp_file - end - - it "sends the RETR command to the server" do - @ftp.send(@method, "test", @tmp_file) - @ftp.last_response.should == "226 Closing data connection. (RETR test)\n" - end - - it "returns nil" do - @ftp.send(@method, "test", @tmp_file).should be_nil - end - - it "saves the contents of the passed remote file to the passed local file" do - @ftp.send(@method, "test", @tmp_file) - File.read(@tmp_file).should == "This is the content\nof the file named 'test'.\n" - end - - describe "when passed a block" do - it "yields the received content as binary blocks of the passed size" do - res = [] - @ftp.send(@method, "test", @tmp_file, 10) { |bin| res << bin } - res.should == [ "This is th", "e content\n", "of the fil", "e named 't", "est'.\n" ] - end - end - - describe "when resuming an existing file" do - before :each do - @tmp_file = tmp("getbinaryfile_resume") - - File.open(@tmp_file, "wb") do |f| - f << "This is the content\n" - end - - @ftp.resume = true - end - - it "saves the remaining content of the passed remote file to the passed local file" do - @ftp.send(@method, "test", @tmp_file) - File.read(@tmp_file).should == "This is the content\nof the file named 'test'.\n" - end - - describe "and the REST command fails" do - it "raises a Net::FTPProtoError when the response code is 550" do - @server.should_receive(:rest).and_respond("Requested action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:rest).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:rest).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:rest).and_respond("502 Command not implemented.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:rest).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:rest).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - end - end - - describe "when the RETR command fails" do - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:retr).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPProtoError when the response code is 550" do - @server.should_receive(:retr).and_respond("Requested action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:retr).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:retr).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:retr).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:retr).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - end - - describe "when opening the data port fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") - @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") - @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") - @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:eprt).and_respond("530 Not logged in.") - @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/shared/gettextfile.rb b/spec/ruby/library/net/ftp/shared/gettextfile.rb deleted file mode 100644 index 82bec2a4a7..0000000000 --- a/spec/ruby/library/net/ftp/shared/gettextfile.rb +++ /dev/null @@ -1,100 +0,0 @@ -describe :net_ftp_gettextfile, shared: :true do - before :each do - @tmp_file = tmp("gettextfile") - - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - @ftp.binary = @binary_mode - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - - rm_r @tmp_file - end - - it "sends the RETR command to the server" do - @ftp.send(@method, "test", @tmp_file) - @ftp.last_response.should == "226 Closing data connection. (RETR test)\n" - end - - it "returns nil" do - @ftp.send(@method, "test", @tmp_file).should be_nil - end - - it "saves the contents of the passed remote file to the passed local file" do - @ftp.send(@method, "test", @tmp_file) - File.read(@tmp_file).should == "This is the content\nof the file named 'test'.\n" - end - - describe "when passed a block" do - it "yields each line of the retrieved file to the passed block" do - res = [] - @ftp.send(@method, "test", @tmp_file) { |line| res << line } - res.should == [ "This is the content", "of the file named 'test'."] - end - end - - describe "when the RETR command fails" do - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:retr).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPProtoError when the response code is 550" do - @server.should_receive(:retr).and_respond("Requested action not taken.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:retr).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:retr).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:retr).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:retr).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - end - - describe "when opening the data port fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") - @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") - @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") - @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:eprt).and_respond("530 Not logged in.") - @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, "test", @tmp_file) }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/shared/last_response_code.rb b/spec/ruby/library/net/ftp/shared/last_response_code.rb deleted file mode 100644 index 4fe53677db..0000000000 --- a/spec/ruby/library/net/ftp/shared/last_response_code.rb +++ /dev/null @@ -1,25 +0,0 @@ -describe :net_ftp_last_response_code, shared: true do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "returns the response code for the last response" do - @server.should_receive(:help).and_respond("200 Command okay.") - @ftp.help - @ftp.send(@method).should == "200" - - @server.should_receive(:help).and_respond("212 Directory status.") - @ftp.help - @ftp.send(@method).should == "212" - end -end diff --git a/spec/ruby/library/net/ftp/shared/list.rb b/spec/ruby/library/net/ftp/shared/list.rb deleted file mode 100644 index adc3fa59c1..0000000000 --- a/spec/ruby/library/net/ftp/shared/list.rb +++ /dev/null @@ -1,104 +0,0 @@ -describe :net_ftp_list, shared: true do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.passive = false - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - describe "when passed a block" do - it "yields each file in the list of files in the passed dir" do - expected = [ - "-rw-r--r-- 1 spec staff 507 17 Jul 18:41 last_response_code.rb", - "-rw-r--r-- 1 spec staff 50 17 Jul 18:41 list.rb", - "-rw-r--r-- 1 spec staff 48 17 Jul 18:41 pwd.rb" - ] - - res = [] - @ftp.send(@method, "test.folder") { |line| res << line} - res.should == expected - - @ftp.last_response.should == "226 transfer complete (LIST test.folder)\n" - end - end - - describe "when passed no block" do - it "returns an Array containing a list of files in the passed dir" do - expected = [ - "-rw-r--r-- 1 spec staff 507 17 Jul 18:41 last_response_code.rb", - "-rw-r--r-- 1 spec staff 50 17 Jul 18:41 list.rb", - "-rw-r--r-- 1 spec staff 48 17 Jul 18:41 pwd.rb" - ] - - @ftp.send(@method, "test.folder").should == expected - - @ftp.last_response.should == "226 transfer complete (LIST test.folder)\n" - end - end - - describe "when the LIST command fails" do - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:list).and_respond("450 Requested file action not taken..") - -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:list).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:list).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:list).and_respond("502 Command not implemented.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:list).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:list).and_respond("530 Not logged in.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - end - - describe "when opening the data port fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") - @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") - @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") - @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:eprt).and_respond("530 Not logged in.") - @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method) }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/shared/putbinaryfile.rb b/spec/ruby/library/net/ftp/shared/putbinaryfile.rb deleted file mode 100644 index 1163a1cfea..0000000000 --- a/spec/ruby/library/net/ftp/shared/putbinaryfile.rb +++ /dev/null @@ -1,167 +0,0 @@ -describe :net_ftp_putbinaryfile, shared: :true do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @local_fixture_file = File.dirname(__FILE__) + "/../fixtures/putbinaryfile" - @remote_tmp_file = tmp("binaryfile", false) - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - @ftp.binary = @binary_mode - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - - rm_r @remote_tmp_file - end - - it "sends the STOR command to the server" do - @ftp.send(@method, @local_fixture_file, "binary") - @ftp.last_response.should == "200 OK, Data received. (STOR binary)\n" - end - - it "sends the contents of the passed local_file, without modifications" do - @ftp.send(@method, @local_fixture_file, "binary") - - remote_lines = File.readlines(@remote_tmp_file) - local_lines = File.readlines(@local_fixture_file) - - remote_lines.should == local_lines - end - - it "returns nil" do - @ftp.send(@method, @local_fixture_file, "binary").should be_nil - end - - describe "when passed a block" do - it "yields the transmitted content as binary blocks of the passed size" do - res = [] - @ftp.send(@method, @local_fixture_file, "binary", 10) { |x| res << x } - res.should == [ - "This is an", " example f", - "ile\nwhich ", "is going t", - "o be trans", "mitted\nusi", - "ng #putbin", "aryfile.\n" - ] - end - end - - describe "when resuming an existing file" do - before :each do - File.open(@remote_tmp_file, "w") do |f| - f << "This is an example file\n" - end - - @ftp.resume = true - end - - it "sends the remaining content of the passed local_file to the passed remote_file" do - @ftp.send(@method, @local_fixture_file, "binary") - File.read(@remote_tmp_file).should == File.read(@local_fixture_file) - end - - describe "and the APPE command fails" do - it "raises a Net::FTPProtoError when the response code is 550" do - @server.should_receive(:appe).and_respond("Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPProtoError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:appe).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:appe).and_respond("501 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:appe).and_respond("502 Command not implemented.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:appe).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:appe).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - end - end - - describe "when the STOR command fails" do - it "raises a Net::FTPPermError when the response code is 532" do - @server.should_receive(:stor).and_respond("532 Need account for storing files.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:stor).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPTempError when the response code is 452" do - @server.should_receive(:stor).and_respond("452 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 553" do - @server.should_receive(:stor).and_respond("553 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:stor).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:stor).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:stor).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:stor).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - end - - describe "when opening the data port fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") - @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") - @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") - @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:eprt).and_respond("530 Not logged in.") - @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "binary") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/shared/puttextfile.rb b/spec/ruby/library/net/ftp/shared/puttextfile.rb deleted file mode 100644 index 50e8de28e6..0000000000 --- a/spec/ruby/library/net/ftp/shared/puttextfile.rb +++ /dev/null @@ -1,120 +0,0 @@ -describe :net_ftp_puttextfile, shared: true do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @local_fixture_file = File.dirname(__FILE__) + "/../fixtures/puttextfile" - @remote_tmp_file = tmp("textfile", false) - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - @ftp.binary = @binary_mode - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - - rm_r @remote_tmp_file - end - - it "sends the STOR command to the server" do - @ftp.send(@method, @local_fixture_file, "text") - @ftp.last_response.should == "200 OK, Data received. (STOR text)\n" - end - - it "sends the contents of the passed local_file, using \\r\\n as the newline separator" do - @ftp.send(@method, @local_fixture_file, "text") - - remote_lines = open(@remote_tmp_file, "rb") {|f| f.read } - local_lines = open(@local_fixture_file, "rb") {|f| f.read } - - remote_lines.should_not == local_lines - remote_lines.should == local_lines.gsub("\n", "\r\n") - end - - it "returns nil" do - @ftp.send(@method, @local_fixture_file, "text").should be_nil - end - - describe "when passed a block" do - it "yields each transmitted line" do - res = [] - @ftp.send(@method, @local_fixture_file, "text") { |x| res << x } - res.should == [ - "This is an example file\r\n", - "which is going to be transmitted\r\n", - "using #puttextfile.\r\n" - ] - end - end - - describe "when the STOR command fails" do - it "raises a Net::FTPPermError when the response code is 532" do - @server.should_receive(:stor).and_respond("532 Need account for storing files.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 450" do - @server.should_receive(:stor).and_respond("450 Requested file action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPTempError when the response code is 452" do - @server.should_receive(:stor).and_respond("452 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 553" do - @server.should_receive(:stor).and_respond("553 Requested action not taken.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:stor).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:stor).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:stor).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:stor).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - end - - describe "when opening the data port fails" do - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.") - @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.") - @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.") - @server.should_receive(:port).and_respond("421 Service not available, closing control connection.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:eprt).and_respond("530 Not logged in.") - @server.should_receive(:port).and_respond("530 Not logged in.") - -> { @ftp.send(@method, @local_fixture_file, "text") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/shared/pwd.rb b/spec/ruby/library/net/ftp/shared/pwd.rb deleted file mode 100644 index 951d020f2d..0000000000 --- a/spec/ruby/library/net/ftp/shared/pwd.rb +++ /dev/null @@ -1,3 +0,0 @@ -describe :net_ftp_pwd, shared: true do - -end diff --git a/spec/ruby/library/net/ftp/site_spec.rb b/spec/ruby/library/net/ftp/site_spec.rb deleted file mode 100644 index ca4f499112..0000000000 --- a/spec/ruby/library/net/ftp/site_spec.rb +++ /dev/null @@ -1,56 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#site" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the SITE command with the passed argument to the server" do - @ftp.site("param") - @ftp.last_response.should == "200 Command okay. (SITE param)\n" - end - - it "returns nil" do - @ftp.site("param").should be_nil - end - - it "does not raise an error when the response code is 202" do - @server.should_receive(:site).and_respond("202 Command not implemented, superfluous at this site.") - -> { @ftp.site("param") }.should_not raise_error - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:site).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.site("param") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:site).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.site("param") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:site).and_respond("421 Service not available, closing control connection.") - -> { @ftp.site("param") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:site).and_respond("530 Requested action not taken.") - -> { @ftp.site("param") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/size_spec.rb b/spec/ruby/library/net/ftp/size_spec.rb deleted file mode 100644 index 0c20b10549..0000000000 --- a/spec/ruby/library/net/ftp/size_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#size" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the SIZE command to the server" do - @ftp.size("test.file") - @ftp.last_response.should == "213 1024\n" - end - - it "returns the size of the passed file as Integer" do - @ftp.size("test.file").should eql(1024) - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:size).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:size).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:size).and_respond("421 Service not available, closing control connection.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 550" do - @server.should_receive(:size).and_respond("550 Requested action not taken.") - -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/spec_helper.rb b/spec/ruby/library/net/ftp/spec_helper.rb deleted file mode 100644 index c87d16218b..0000000000 --- a/spec/ruby/library/net/ftp/spec_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "net/ftp" - -if defined?(Net::FTP.default_passive) - Net::FTP.default_passive = false -end diff --git a/spec/ruby/library/net/ftp/status_spec.rb b/spec/ruby/library/net/ftp/status_spec.rb deleted file mode 100644 index 03bc5d6e05..0000000000 --- a/spec/ruby/library/net/ftp/status_spec.rb +++ /dev/null @@ -1,70 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#status" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the STAT command to the server" do - @ftp.status - @ftp.last_response.should == "211 System status, or system help reply. (STAT)\n" - end - - 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 - - it "returns the received information" do - @ftp.status.should == "211 System status, or system help reply. (STAT)\n" - end - - it "does not raise an error when the response code is 212" do - @server.should_receive(:stat).and_respond("212 Directory status.") - -> { @ftp.status }.should_not raise_error - end - - it "does not raise an error when the response code is 213" do - @server.should_receive(:stat).and_respond("213 File status.") - -> { @ftp.status }.should_not raise_error - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:stat).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:stat).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:stat).and_respond("502 Command not implemented.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:stat).and_respond("421 Service not available, closing control connection.") - -> { @ftp.status }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 530" do - @server.should_receive(:stat).and_respond("530 Requested action not taken.") - -> { @ftp.status }.should raise_error(Net::FTPPermError) - end - end -end diff --git a/spec/ruby/library/net/ftp/storbinary_spec.rb b/spec/ruby/library/net/ftp/storbinary_spec.rb deleted file mode 100644 index 64c9090760..0000000000 --- a/spec/ruby/library/net/ftp/storbinary_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#storbinary" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @local_fixture_file = File.dirname(__FILE__) + "/fixtures/putbinaryfile" - @tmp_file = tmp("binaryfile", false) - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - - rm_r @tmp_file - end - - it "sends the passed command and the passed File object's content to the server" do - File.open(@local_fixture_file) do |f| - f.binmode - - @ftp.storbinary("STOR binary", f, 4096) {} - @ftp.last_response.should == "200 OK, Data received. (STOR binary)\n" - end - end - - it "yields the transmitted content as binary blocks of the passed size" do - File.open(@local_fixture_file) do |f| - f.binmode - - res = [] - @ftp.storbinary("STOR binary", f, 10) { |x| res << x } - res.should == [ - "This is an", " example f", - "ile\nwhich ", "is going t", - "o be trans", "mitted\nusi", - "ng #putbin", "aryfile.\n" - ] - end - end - end -end diff --git a/spec/ruby/library/net/ftp/storlines_spec.rb b/spec/ruby/library/net/ftp/storlines_spec.rb deleted file mode 100644 index a4bb7af799..0000000000 --- a/spec/ruby/library/net/ftp/storlines_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#storlines" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @local_fixture_file = File.dirname(__FILE__) + "/fixtures/puttextfile" - @tmp_file = tmp("textfile", false) - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - - rm_r @tmp_file - end - - it "sends the passed command and the passed File object's content to the server" do - File.open(@local_fixture_file) do |f| - @ftp.storlines("STOR text", f) {} - @ftp.last_response.should == "200 OK, Data received. (STOR text)\n" - end - end - - it "yields each line of the transmitted content" do - File.open(@local_fixture_file) do |f| - res = [] - @ftp.storlines("STOR text", f) { |x| res << x } - res.should == [ - "This is an example file\r\n", - "which is going to be transmitted\r\n", - "using #puttextfile.\r\n" - ] - end - end - end -end diff --git a/spec/ruby/library/net/ftp/system_spec.rb b/spec/ruby/library/net/ftp/system_spec.rb deleted file mode 100644 index 0630bbe1f6..0000000000 --- a/spec/ruby/library/net/ftp/system_spec.rb +++ /dev/null @@ -1,51 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#system" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the SYST command to the server" do - @ftp.system - @ftp.last_response.should =~ /\A215 FTP Dummy Server \(SYST\)\Z/ - end - - it "returns the received information" do - @ftp.system.should =~ /\AFTP Dummy Server \(SYST\)\Z/ - end - - it "raises a Net::FTPPermError when the response code is 500" do - @server.should_receive(:syst).and_respond("500 Syntax error, command unrecognized.") - -> { @ftp.system }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 501" do - @server.should_receive(:syst).and_respond("501 Syntax error in parameters or arguments.") - -> { @ftp.system }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPPermError when the response code is 502" do - @server.should_receive(:syst).and_respond("502 Command not implemented.") - -> { @ftp.system }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPTempError when the response code is 421" do - @server.should_receive(:syst).and_respond("421 Service not available, closing control connection.") - -> { @ftp.system }.should raise_error(Net::FTPTempError) - end - end -end diff --git a/spec/ruby/library/net/ftp/voidcmd_spec.rb b/spec/ruby/library/net/ftp/voidcmd_spec.rb deleted file mode 100644 index ee74455d63..0000000000 --- a/spec/ruby/library/net/ftp/voidcmd_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#voidcmd" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "sends the passed command to the server" do - @server.should_receive(:help).and_respond("2xx Does not raise.") - -> { @ftp.voidcmd("HELP") }.should_not raise_error - end - - it "returns nil" do - @server.should_receive(:help).and_respond("2xx Does not raise.") - @ftp.voidcmd("HELP").should be_nil - end - - it "raises a Net::FTPReplyError when the response code is 1xx" do - @server.should_receive(:help).and_respond("1xx Does raise a Net::FTPReplyError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError) - end - - it "raises a Net::FTPReplyError when the response code is 3xx" do - @server.should_receive(:help).and_respond("3xx Does raise a Net::FTPReplyError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPReplyError) - end - - it "raises a Net::FTPTempError when the response code is 4xx" do - @server.should_receive(:help).and_respond("4xx Does raise a Net::FTPTempError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPTempError) - end - - it "raises a Net::FTPPermError when the response code is 5xx" do - @server.should_receive(:help).and_respond("5xx Does raise a Net::FTPPermError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPPermError) - end - - it "raises a Net::FTPProtoError when the response code is not valid" do - @server.should_receive(:help).and_respond("999 Does raise a Net::FTPProtoError.") - -> { @ftp.voidcmd("HELP") }.should raise_error(Net::FTPProtoError) - end - end -end diff --git a/spec/ruby/library/net/ftp/welcome_spec.rb b/spec/ruby/library/net/ftp/welcome_spec.rb deleted file mode 100644 index e5414ef607..0000000000 --- a/spec/ruby/library/net/ftp/welcome_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative '../../../spec_helper' - -ruby_version_is ""..."3.1" do - require_relative 'spec_helper' - require_relative 'fixtures/server' - - describe "Net::FTP#welcome" do - before :each do - @server = NetFTPSpecs::DummyFTP.new - @server.serve_once - - @ftp = Net::FTP.new - @ftp.connect(@server.hostname, @server.server_port) - end - - after :each do - @ftp.quit rescue nil - @ftp.close - @server.stop - end - - it "returns the server's welcome message" do - @ftp.welcome.should be_nil - @ftp.login - @ftp.welcome.should == "230 User logged in, proceed. (USER anonymous)\n" - end - end -end diff --git a/spec/ruby/library/net/http/HTTPBadResponse_spec.rb b/spec/ruby/library/net/http/HTTPBadResponse_spec.rb deleted file mode 100644 index be644968f5..0000000000 --- a/spec/ruby/library/net/http/HTTPBadResponse_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -describe "Net::HTTPBadResponse" do - it "is a subclass of StandardError" do - Net::HTTPBadResponse.should < StandardError - end -end diff --git a/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb b/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb deleted file mode 100644 index d576349a57..0000000000 --- a/spec/ruby/library/net/http/HTTPClientExcepton_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -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 diff --git a/spec/ruby/library/net/http/HTTPError_spec.rb b/spec/ruby/library/net/http/HTTPError_spec.rb deleted file mode 100644 index ab5f491bb7..0000000000 --- a/spec/ruby/library/net/http/HTTPError_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -describe "Net::HTTPError" do - it "is a subclass of Net::ProtocolError" do - Net::HTTPError.should < Net::ProtocolError - end - - it "includes the Net::HTTPExceptions module" do - Net::HTTPError.should < Net::HTTPExceptions - end -end diff --git a/spec/ruby/library/net/http/HTTPFatalError_spec.rb b/spec/ruby/library/net/http/HTTPFatalError_spec.rb deleted file mode 100644 index 6ab36bff6c..0000000000 --- a/spec/ruby/library/net/http/HTTPFatalError_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -describe "Net::HTTPFatalError" do - it "is a subclass of Net::ProtoFatalError" do - Net::HTTPFatalError.should < Net::ProtoFatalError - end - - it "includes the Net::HTTPExceptions module" do - Net::HTTPFatalError.should < Net::HTTPExceptions - end -end diff --git a/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb b/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb deleted file mode 100644 index 38e9454f99..0000000000 --- a/spec/ruby/library/net/http/HTTPHeaderSyntaxError_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -describe "Net::HTTPHeaderSyntaxError" do - it "is a subclass of StandardError" do - Net::HTTPHeaderSyntaxError.should < StandardError - end -end diff --git a/spec/ruby/library/net/http/HTTPRetriableError_spec.rb b/spec/ruby/library/net/http/HTTPRetriableError_spec.rb deleted file mode 100644 index 3a4bb9146c..0000000000 --- a/spec/ruby/library/net/http/HTTPRetriableError_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -describe "Net::HTTPRetriableError" do - it "is a subclass of Net::ProtoRetriableError" do - Net::HTTPRetriableError.should < Net::ProtoRetriableError - end - - it "includes the Net::HTTPExceptions module" do - Net::HTTPRetriableError.should < Net::HTTPExceptions - end -end diff --git a/spec/ruby/library/net/http/HTTPServerException_spec.rb b/spec/ruby/library/net/http/HTTPServerException_spec.rb deleted file mode 100644 index 23b0657364..0000000000 --- a/spec/ruby/library/net/http/HTTPServerException_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../spec_helper' -require 'net/http' - -describe "Net::HTTPServerException" do - it "is a subclass of Net::ProtoServerError and is warned as deprecated" do - -> { 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 - -> { Net::HTTPServerException.should < Net::HTTPExceptions }.should complain(/warning: constant Net::HTTPServerException is deprecated/) - end -end diff --git a/spec/ruby/library/net/http/http/Proxy_spec.rb b/spec/ruby/library/net/http/http/Proxy_spec.rb deleted file mode 100644 index f85ccc0ee9..0000000000 --- a/spec/ruby/library/net/http/http/Proxy_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.Proxy" do - it "returns a new subclass of Net::HTTP" do - Net::HTTP.Proxy("localhost").should < Net::HTTP - end - - it "returns Net::HTTP when the passed address is nil" do - Net::HTTP.Proxy(nil).should == Net::HTTP - end - - it "sets the returned subclasses' proxy options based on the passed arguments" do - http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.proxy_address.should == "localhost" - http_with_proxy.proxy_port.should eql(1234) - http_with_proxy.proxy_user.should == "rspec" - http_with_proxy.proxy_pass.should == "rocks" - end -end - -describe "Net::HTTP#proxy?" do - describe "when self is no proxy class instance" do - it "returns false" do - Net::HTTP.new("localhost", 3333).proxy?.should be_false - end - end - - describe "when self is a proxy class instance" do - it "returns false" do - http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy?.should be_true - end - end -end diff --git a/spec/ruby/library/net/http/http/active_spec.rb b/spec/ruby/library/net/http/http/active_spec.rb deleted file mode 100644 index ef657243ba..0000000000 --- a/spec/ruby/library/net/http/http/active_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/started' - -describe "Net::HTTP#active?" do - it_behaves_like :net_http_started_p, :active? -end diff --git a/spec/ruby/library/net/http/http/address_spec.rb b/spec/ruby/library/net/http/http/address_spec.rb deleted file mode 100644 index 5fce76d767..0000000000 --- a/spec/ruby/library/net/http/http/address_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#address" do - it "returns the current host name" do - net = Net::HTTP.new("localhost") - net.address.should == "localhost" - end -end diff --git a/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb b/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb deleted file mode 100644 index a97b7b6c43..0000000000 --- a/spec/ruby/library/net/http/http/close_on_empty_response_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#close_on_empty_response" do - it "needs to be reviewed for spec completeness" -end - -describe "Net::HTTP#close_on_empty_response=" do - it "needs to be reviewed for spec completeness" -end diff --git a/spec/ruby/library/net/http/http/copy_spec.rb b/spec/ruby/library/net/http/http/copy_spec.rb deleted file mode 100644 index 5ebfdc334e..0000000000 --- a/spec/ruby/library/net/http/http/copy_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#copy" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a COPY request to the passed path and returns the response" do - response = @http.copy("/request") - response.should be_kind_of(Net::HTTPResponse) - response.body.should == "Request type: COPY" - end -end diff --git a/spec/ruby/library/net/http/http/default_port_spec.rb b/spec/ruby/library/net/http/http/default_port_spec.rb deleted file mode 100644 index 30db18efae..0000000000 --- a/spec/ruby/library/net/http/http/default_port_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.default_port" do - it "returns 80" do - Net::HTTP.http_default_port.should eql(80) - end -end diff --git a/spec/ruby/library/net/http/http/delete_spec.rb b/spec/ruby/library/net/http/http/delete_spec.rb deleted file mode 100644 index 160c653115..0000000000 --- a/spec/ruby/library/net/http/http/delete_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#delete" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a DELETE request to the passed path and returns the response" do - response = @http.delete("/request") - response.should be_kind_of(Net::HTTPResponse) - response.body.should == "Request type: DELETE" - end -end diff --git a/spec/ruby/library/net/http/http/finish_spec.rb b/spec/ruby/library/net/http/http/finish_spec.rb deleted file mode 100644 index f98bc7be13..0000000000 --- a/spec/ruby/library/net/http/http/finish_spec.rb +++ /dev/null @@ -1,29 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#finish" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.new("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when self has been started" do - it "closes the tcp connection" do - @http.start - @http.finish - @http.started?.should be_false - end - end - - describe "when self has not been started yet" do - it "raises an IOError" do - -> { @http.finish }.should raise_error(IOError) - end - end -end diff --git a/spec/ruby/library/net/http/http/fixtures/http_server.rb b/spec/ruby/library/net/http/http/fixtures/http_server.rb deleted file mode 100644 index 63543b46a9..0000000000 --- a/spec/ruby/library/net/http/http/fixtures/http_server.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'socket' - -module NetHTTPSpecs - class NullWriter - def <<(s) end - def puts(*args) end - def print(*args) end - def printf(*args) end - end - - class SmallHTTPServer - def initialize(bind_address) - @server = TCPServer.new(bind_address, 0) - @running = Mutex.new - @thread = Thread.new { - Thread.current.abort_on_exception = true - listen - } - end - - def port - @server.addr[1] - end - - def listen - loop do - begin - client = @server.accept - rescue IOError => e - if @running.locked? # close - break - else - raise e - end - end - - handle_client(client) - end - end - - def handle_client(client) - begin - until client.closed? - request = client.gets("\r\n\r\n") - break unless request - handle_request(client, request) - end - ensure - client.close - end - end - - def parse_request(request) - request, *headers = request.chomp.lines.map { |line| line.chomp } - request_method, request_uri, _http_version = request.split - headers = headers.map { |line| line.split(': ', 2) }.to_h - [request_method, request_uri, headers] - end - - def handle_request(client, request) - request_method, request_uri, headers = parse_request(request) - - if headers.include? 'Content-Length' - request_body_size = Integer(headers['Content-Length']) - request_body = client.read(request_body_size) - end - - case request_uri - when '/' - raise request_method unless request_method == 'GET' - reply(client, "This is the index page.", request_method) - when '/request' - reply(client, "Request type: #{request_method}", request_method) - when '/request/body' - reply(client, request_body, request_method) - when '/request/header' - reply(client, headers.inspect, request_method) - when '/request/basic_auth' - reply(client, "username: \npassword: ", request_method) - else - raise request_uri - end - end - - def reply(client, body, request_method) - client.print "HTTP/1.1 200 OK\r\n" - if request_method == 'HEAD' - client.close - else - client.print "Content-Type: text/plain\r\n" - client.print "Content-Length: #{body.bytesize}\r\n" - client.print "\r\n" - client.print body - end - end - - def close - @running.lock - @server.close - @thread.join - end - end - - @server = nil - - class << self - def port - raise "server not started" unless @server - @server.port - end - - def start_server - bind_address = platform_is(:windows) ? "localhost" : "127.0.0.1" - @server = SmallHTTPServer.new(bind_address) - end - - def stop_server - if @server - @server.close - @server = nil - end - end - end -end diff --git a/spec/ruby/library/net/http/http/get2_spec.rb b/spec/ruby/library/net/http/http/get2_spec.rb deleted file mode 100644 index 519e4c2599..0000000000 --- a/spec/ruby/library/net/http/http/get2_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_get' - -describe "Net::HTTP#get2" do - it_behaves_like :net_http_request_get, :get2 -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 deleted file mode 100644 index f59dd68c81..0000000000 --- a/spec/ruby/library/net/http/http/get_print_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP.get_print" do - before :each do - NetHTTPSpecs.start_server - @port = NetHTTPSpecs.port - end - - after :each do - NetHTTPSpecs.stop_server - end - - describe "when passed URI" do - it "it prints the body of the specified uri to $stdout" do - -> do - Net::HTTP.get_print URI.parse("http://localhost:#{@port}/") - end.should output(/This is the index page\./) - end - end - - describe "when passed host, path, port" do - it "it prints the body of the specified uri to $stdout" do - -> do - Net::HTTP.get_print 'localhost', "/", @port - end.should output(/This is the index page\./) - end - end -end diff --git a/spec/ruby/library/net/http/http/get_response_spec.rb b/spec/ruby/library/net/http/http/get_response_spec.rb deleted file mode 100644 index 941b35e773..0000000000 --- a/spec/ruby/library/net/http/http/get_response_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP.get_response" do - before :each do - NetHTTPSpecs.start_server - @port = NetHTTPSpecs.port - end - - after :each do - NetHTTPSpecs.stop_server - end - - describe "when passed URI" do - it "returns the response for the specified uri" do - res = Net::HTTP.get_response(URI.parse("http://localhost:#{@port}/")) - res.content_type.should == "text/plain" - res.body.should == "This is the index page." - end - end - - describe "when passed host, path, port" do - it "returns the response for the specified host-path-combination" do - res = Net::HTTP.get_response('localhost', "/", @port) - res.content_type.should == "text/plain" - res.body.should == "This is the index page." - end - end -end diff --git a/spec/ruby/library/net/http/http/get_spec.rb b/spec/ruby/library/net/http/http/get_spec.rb deleted file mode 100644 index 9f6c45f26b..0000000000 --- a/spec/ruby/library/net/http/http/get_spec.rb +++ /dev/null @@ -1,96 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP.get" do - before :each do - NetHTTPSpecs.start_server - @port = NetHTTPSpecs.port - end - - after :each do - NetHTTPSpecs.stop_server - end - - describe "when passed URI" do - it "returns the body of the specified uri" do - Net::HTTP.get(URI.parse("http://localhost:#{@port}/")).should == "This is the index page." - end - end - - describe "when passed host, path, port" do - it "returns the body of the specified host-path-combination" do - Net::HTTP.get('localhost', "/", @port).should == "This is the index page." - end - end -end - -quarantine! do # These specs fail frequently with CHECK_LEAKS=true -describe "Net::HTTP.get" do - describe "when reading gzipped contents" do - def start_threads - require 'zlib' - require 'stringio' - - server = nil - server_thread = Thread.new do - server = TCPServer.new("127.0.0.1", 0) - begin - c = server.accept - ensure - server.close - end - c.print "HTTP/1.1 200\r\n" - c.print "Content-Type: text/plain\r\n" - c.print "Content-Encoding: gzip\r\n" - s = StringIO.new - z = Zlib::GzipWriter.new(s) - begin - z.write 'Hello World!' - ensure - z.close - end - c.print "Content-Length: #{s.length}\r\n\r\n" - # Write partial gzip content - c.write s.string.byteslice(0..-2) - c.flush - c - end - Thread.pass until server && server_thread.stop? - - client_thread = Thread.new do - Thread.current.report_on_exception = false - Net::HTTP.get("127.0.0.1", '/', server.connect_address.ip_port) - end - - socket = server_thread.value - Thread.pass until client_thread.stop? - - [socket, client_thread] - end - - it "propagates exceptions interrupting the thread and does not replace it with Zlib::BufError" do - my_exception = Class.new(RuntimeError) - socket, client_thread = start_threads - begin - client_thread.raise my_exception, "my exception" - -> { client_thread.value }.should raise_error(my_exception) - ensure - socket.close - end - end - - ruby_version_is "3.0" do # https://bugs.ruby-lang.org/issues/13882#note-6 - it "lets the kill Thread exception goes through and does not replace it with Zlib::BufError" do - socket, client_thread = start_threads - begin - client_thread.kill - client_thread.value.should == nil - ensure - socket.close - end - end - end - end -end -end diff --git a/spec/ruby/library/net/http/http/head2_spec.rb b/spec/ruby/library/net/http/http/head2_spec.rb deleted file mode 100644 index 6958204ee1..0000000000 --- a/spec/ruby/library/net/http/http/head2_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_head' - -describe "Net::HTTP#head2" do - it_behaves_like :net_http_request_head, :head2 -end diff --git a/spec/ruby/library/net/http/http/head_spec.rb b/spec/ruby/library/net/http/http/head_spec.rb deleted file mode 100644 index 925a8e6043..0000000000 --- a/spec/ruby/library/net/http/http/head_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#head" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a HEAD request to the passed path and returns the response" do - response = @http.head("/request") - # HEAD requests have no responses - response.body.should be_nil - end - - it "returns a Net::HTTPResponse" do - @http.head("/request").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/http_default_port_spec.rb b/spec/ruby/library/net/http/http/http_default_port_spec.rb deleted file mode 100644 index cf7f73e630..0000000000 --- a/spec/ruby/library/net/http/http/http_default_port_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.http_default_port" do - it "returns 80" do - Net::HTTP.http_default_port.should eql(80) - end -end diff --git a/spec/ruby/library/net/http/http/https_default_port_spec.rb b/spec/ruby/library/net/http/http/https_default_port_spec.rb deleted file mode 100644 index fbf0bd1abc..0000000000 --- a/spec/ruby/library/net/http/http/https_default_port_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.https_default_port" do - it "returns 443" do - Net::HTTP.https_default_port.should eql(443) - end -end diff --git a/spec/ruby/library/net/http/http/initialize_spec.rb b/spec/ruby/library/net/http/http/initialize_spec.rb deleted file mode 100644 index 7683713a0e..0000000000 --- a/spec/ruby/library/net/http/http/initialize_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#initialize" do - it "is private" do - Net::HTTP.should have_private_instance_method(:initialize) - end - - describe "when passed address" do - before :each do - @net = Net::HTTP.allocate - @net.send(:initialize, "localhost") - end - - it "sets the new Net::HTTP instance's address to the passed address" do - @net.address.should == "localhost" - end - - it "sets the new Net::HTTP instance's port to the default HTTP port" do - @net.port.should eql(Net::HTTP.default_port) - end - - it "does not start the new Net::HTTP instance" do - @net.started?.should be_false - end - end - - describe "when passed address, port" do - before :each do - @net = Net::HTTP.allocate - @net.send(:initialize, "localhost", 3333) - end - - it "sets the new Net::HTTP instance's address to the passed address" do - @net.address.should == "localhost" - end - - it "sets the new Net::HTTP instance's port to the passed port" do - @net.port.should eql(3333) - end - - it "does not start the new Net::HTTP instance" do - @net.started?.should be_false - end - end -end diff --git a/spec/ruby/library/net/http/http/inspect_spec.rb b/spec/ruby/library/net/http/http/inspect_spec.rb deleted file mode 100644 index b1e799ca34..0000000000 --- a/spec/ruby/library/net/http/http/inspect_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#inspect" do - before :each do - NetHTTPSpecs.start_server - @port = NetHTTPSpecs.port - @http = Net::HTTP.new("localhost", @port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "returns a String representation of self" do - @http.inspect.should be_kind_of(String) - @http.inspect.should == "#<Net::HTTP localhost:#{@port} open=false>" - - @http.start - @http.inspect.should == "#<Net::HTTP localhost:#{@port} open=true>" - end -end diff --git a/spec/ruby/library/net/http/http/is_version_1_1_spec.rb b/spec/ruby/library/net/http/http/is_version_1_1_spec.rb deleted file mode 100644 index f37695b777..0000000000 --- a/spec/ruby/library/net/http/http/is_version_1_1_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'shared/version_1_1' - -describe "Net::HTTP.is_version_1_1?" do - it_behaves_like :net_http_version_1_1_p, :is_version_1_1? -end diff --git a/spec/ruby/library/net/http/http/is_version_1_2_spec.rb b/spec/ruby/library/net/http/http/is_version_1_2_spec.rb deleted file mode 100644 index 82dbdc87aa..0000000000 --- a/spec/ruby/library/net/http/http/is_version_1_2_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'shared/version_1_2' - -describe "Net::HTTP.is_version_1_2?" do - it_behaves_like :net_http_version_1_2_p, :is_version_1_2? -end diff --git a/spec/ruby/library/net/http/http/lock_spec.rb b/spec/ruby/library/net/http/http/lock_spec.rb deleted file mode 100644 index bb76607a8b..0000000000 --- a/spec/ruby/library/net/http/http/lock_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#lock" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a LOCK request to the passed path and returns the response" do - response = @http.lock("/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) - response.body.should == "Request type: LOCK" - end -end diff --git a/spec/ruby/library/net/http/http/mkcol_spec.rb b/spec/ruby/library/net/http/http/mkcol_spec.rb deleted file mode 100644 index 33017625e2..0000000000 --- a/spec/ruby/library/net/http/http/mkcol_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#mkcol" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a MKCOL request to the passed path and returns the response" do - response = @http.mkcol("/request") - response.should be_kind_of(Net::HTTPResponse) - response.body.should == "Request type: MKCOL" - end -end diff --git a/spec/ruby/library/net/http/http/move_spec.rb b/spec/ruby/library/net/http/http/move_spec.rb deleted file mode 100644 index 4d6b828150..0000000000 --- a/spec/ruby/library/net/http/http/move_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#head" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a MOVE request to the passed path and returns the response" do - response = @http.move("/request") - # HEAD requests have no responses - response.body.should == "Request type: MOVE" - end - - it "returns a Net::HTTPResponse" do - @http.move("/request").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/new_spec.rb b/spec/ruby/library/net/http/http/new_spec.rb deleted file mode 100644 index 491d1d01fd..0000000000 --- a/spec/ruby/library/net/http/http/new_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.new" do - describe "when passed address" do - before :each do - @http = Net::HTTP.new("localhost") - end - - it "returns a Net::HTTP instance" do - @http.proxy?.should be_false - @http.instance_of?(Net::HTTP).should be_true - end - - it "sets the new Net::HTTP instance's address to the passed address" do - @http.address.should == "localhost" - end - - it "sets the new Net::HTTP instance's port to the default HTTP port" do - @http.port.should eql(Net::HTTP.default_port) - end - - it "does not start the new Net::HTTP instance" do - @http.started?.should be_false - end - end - - describe "when passed address, port" do - before :each do - @http = Net::HTTP.new("localhost", 3333) - end - - it "returns a Net::HTTP instance" do - @http.proxy?.should be_false - @http.instance_of?(Net::HTTP).should be_true - end - - it "sets the new Net::HTTP instance's address to the passed address" do - @http.address.should == "localhost" - end - - it "sets the new Net::HTTP instance's port to the passed port" do - @http.port.should eql(3333) - end - - it "does not start the new Net::HTTP instance" do - @http.started?.should be_false - end - end - - describe "when passed address, port, *proxy_options" do - it "returns a Net::HTTP instance" do - http = Net::HTTP.new("localhost", 3333, "localhost") - http.proxy?.should be_true - http.instance_of?(Net::HTTP).should be_true - http.should be_kind_of(Net::HTTP) - end - - it "correctly sets the passed Proxy options" do - http = Net::HTTP.new("localhost", 3333, "localhost") - http.proxy_address.should == "localhost" - http.proxy_port.should eql(80) - http.proxy_user.should be_nil - http.proxy_pass.should be_nil - - http = Net::HTTP.new("localhost", 3333, "localhost", 1234) - http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) - http.proxy_user.should be_nil - http.proxy_pass.should be_nil - - http = Net::HTTP.new("localhost", 3333, "localhost", 1234, "rubyspec") - http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) - http.proxy_user.should == "rubyspec" - http.proxy_pass.should be_nil - - http = Net::HTTP.new("localhost", 3333, "localhost", 1234, "rubyspec", "rocks") - http.proxy_address.should == "localhost" - http.proxy_port.should eql(1234) - http.proxy_user.should == "rubyspec" - http.proxy_pass.should == "rocks" - end - end - -end diff --git a/spec/ruby/library/net/http/http/newobj_spec.rb b/spec/ruby/library/net/http/http/newobj_spec.rb deleted file mode 100644 index b261dcc5db..0000000000 --- a/spec/ruby/library/net/http/http/newobj_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.newobj" do - before :each do - @net = Net::HTTP.newobj("localhost") - end - - describe "when passed address" do - it "returns a new Net::HTTP instance" do - @net.should be_kind_of(Net::HTTP) - end - - it "sets the new Net::HTTP instance's address to the passed address" do - @net.address.should == "localhost" - end - - it "sets the new Net::HTTP instance's port to the default HTTP port" do - @net.port.should eql(Net::HTTP.default_port) - end - - it "does not start the new Net::HTTP instance" do - @net.started?.should be_false - end - end - - describe "when passed address, port" do - before :each do - @net = Net::HTTP.newobj("localhost", 3333) - end - - it "returns a new Net::HTTP instance" do - @net.should be_kind_of(Net::HTTP) - end - - it "sets the new Net::HTTP instance's address to the passed address" do - @net.address.should == "localhost" - end - - it "sets the new Net::HTTP instance's port to the passed port" do - @net.port.should eql(3333) - end - - it "does not start the new Net::HTTP instance" do - @net.started?.should be_false - end - end -end diff --git a/spec/ruby/library/net/http/http/open_timeout_spec.rb b/spec/ruby/library/net/http/http/open_timeout_spec.rb deleted file mode 100644 index 44b33615e6..0000000000 --- a/spec/ruby/library/net/http/http/open_timeout_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#open_timeout" do - it "returns the seconds to wait till the connection is open" do - net = Net::HTTP.new("localhost") - net.open_timeout.should eql(60) - net.open_timeout = 10 - net.open_timeout.should eql(10) - end -end - -describe "Net::HTTP#open_timeout=" do - it "sets the seconds to wait till the connection is open" do - net = Net::HTTP.new("localhost") - net.open_timeout = 10 - net.open_timeout.should eql(10) - end - - it "returns the newly set value" do - net = Net::HTTP.new("localhost") - (net.open_timeout = 10).should eql(10) - end -end diff --git a/spec/ruby/library/net/http/http/options_spec.rb b/spec/ruby/library/net/http/http/options_spec.rb deleted file mode 100644 index d798e69197..0000000000 --- a/spec/ruby/library/net/http/http/options_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#options" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends an options request to the passed path and returns the response" do - response = @http.options("/request") - - response.body.should == "Request type: OPTIONS" - end - - it "returns a Net::HTTPResponse" do - @http.options("/request").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/port_spec.rb b/spec/ruby/library/net/http/http/port_spec.rb deleted file mode 100644 index 7de295ca75..0000000000 --- a/spec/ruby/library/net/http/http/port_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#port" do - it "returns the current port number" do - net = Net::HTTP.new("localhost", 3333) - net.port.should eql(3333) - end -end diff --git a/spec/ruby/library/net/http/http/post2_spec.rb b/spec/ruby/library/net/http/http/post2_spec.rb deleted file mode 100644 index ccc95068fb..0000000000 --- a/spec/ruby/library/net/http/http/post2_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_post' - -describe "Net::HTTP#post2" do - it_behaves_like :net_http_request_post, :post2 -end diff --git a/spec/ruby/library/net/http/http/post_form_spec.rb b/spec/ruby/library/net/http/http/post_form_spec.rb deleted file mode 100644 index 891e05e7af..0000000000 --- a/spec/ruby/library/net/http/http/post_form_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP.post_form when passed URI" do - before :each do - NetHTTPSpecs.start_server - @port = NetHTTPSpecs.port - end - - after :each do - NetHTTPSpecs.stop_server - end - - it "POSTs the passed form data to the given uri" do - uri = URI.parse("http://localhost:#{@port}/request/body") - data = { test: :data } - - res = Net::HTTP.post_form(uri, data) - res.body.should == "test=data" - end -end diff --git a/spec/ruby/library/net/http/http/post_spec.rb b/spec/ruby/library/net/http/http/post_spec.rb deleted file mode 100644 index 891e20aaca..0000000000 --- a/spec/ruby/library/net/http/http/post_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require 'uri' -require_relative 'fixtures/http_server' - -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 - -describe "Net::HTTP#post" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends an post request to the passed path and returns the response" do - response = @http.post("/request", "test=test") - response.body.should == "Request type: POST" - end - - it "returns a Net::HTTPResponse" do - @http.post("/request", "test=test").should be_kind_of(Net::HTTPResponse) - end - - describe "when passed a block" do - it "yields fragments of the response body to the passed block" do - str = "" - @http.post("/request", "test=test") do |res| - str << res - end - str.should == "Request type: POST" - end - - it "returns a Net::HTTPResponse" do - @http.post("/request", "test=test") {}.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net/http/http/propfind_spec.rb b/spec/ruby/library/net/http/http/propfind_spec.rb deleted file mode 100644 index 5240171618..0000000000 --- a/spec/ruby/library/net/http/http/propfind_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#propfind" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends an propfind request to the passed path and returns the response" do - response = @http.propfind("/request", "test=test") - response.body.should == "Request type: PROPFIND" - end - - it "returns a Net::HTTPResponse" do - @http.propfind("/request", "test=test").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/proppatch_spec.rb b/spec/ruby/library/net/http/http/proppatch_spec.rb deleted file mode 100644 index 7a761a9f23..0000000000 --- a/spec/ruby/library/net/http/http/proppatch_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#proppatch" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends an proppatch request to the passed path and returns the response" do - response = @http.proppatch("/request", "test=test") - response.body.should == "Request type: PROPPATCH" - end - - it "returns a Net::HTTPResponse" do - @http.proppatch("/request", "test=test").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/proxy_address_spec.rb b/spec/ruby/library/net/http/http/proxy_address_spec.rb deleted file mode 100644 index 8d152b8d44..0000000000 --- a/spec/ruby/library/net/http/http/proxy_address_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.proxy_address" do - describe "when self is no proxy class" do - it "returns nil" do - Net::HTTP.proxy_address.should be_nil - end - end - - describe "when self is a proxy class" do - it "returns the address for self's proxy connection" do - Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_address.should == "localhost" - end - end -end - -describe "Net::HTTP#proxy_address" do - describe "when self is no proxy class instance" do - it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_address.should be_nil - end - end - - describe "when self is a proxy class instance" do - it "returns the password for self's proxy connection" do - http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy_address.should == "localhost" - end - end -end diff --git a/spec/ruby/library/net/http/http/proxy_class_spec.rb b/spec/ruby/library/net/http/http/proxy_class_spec.rb deleted file mode 100644 index 2d32a39f01..0000000000 --- a/spec/ruby/library/net/http/http/proxy_class_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.proxy_class?" do - it "returns true if self is a class created with Net::HTTP.Proxy" do - Net::HTTP.proxy_class?.should be_false - Net::HTTP.Proxy("localhost").proxy_class?.should be_true - end -end diff --git a/spec/ruby/library/net/http/http/proxy_pass_spec.rb b/spec/ruby/library/net/http/http/proxy_pass_spec.rb deleted file mode 100644 index 94a0034544..0000000000 --- a/spec/ruby/library/net/http/http/proxy_pass_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.proxy_pass" do - describe "when self is no proxy class" do - it "returns nil" do - Net::HTTP.proxy_pass.should be_nil - end - end - - describe "when self is a proxy class" do - it "returns nil if no password was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_pass.should be_nil - end - - it "returns the password for self's proxy connection" do - Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_pass.should == "rocks" - end - end -end - -describe "Net::HTTP#proxy_pass" do - describe "when self is no proxy class instance" do - it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_pass.should be_nil - end - end - - describe "when self is a proxy class instance" do - it "returns nil if no password was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_pass.should be_nil - end - - it "returns the password for self's proxy connection" do - http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy_pass.should == "rocks" - end - end -end diff --git a/spec/ruby/library/net/http/http/proxy_port_spec.rb b/spec/ruby/library/net/http/http/proxy_port_spec.rb deleted file mode 100644 index 339f7ee850..0000000000 --- a/spec/ruby/library/net/http/http/proxy_port_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.proxy_port" do - describe "when self is no proxy class" do - it "returns nil" do - Net::HTTP.proxy_port.should be_nil - end - end - - describe "when self is a proxy class" do - it "returns 80 if no port was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_port.should eql(80) - end - - it "returns the port for self's proxy connection" do - Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_port.should eql(1234) - end - end -end - -describe "Net::HTTP#proxy_port" do - describe "when self is no proxy class instance" do - it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_port.should be_nil - end - end - - describe "when self is a proxy class instance" do - it "returns 80 if no port was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_port.should eql(80) - end - - it "returns the port for self's proxy connection" do - http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy_port.should eql(1234) - end - end -end diff --git a/spec/ruby/library/net/http/http/proxy_user_spec.rb b/spec/ruby/library/net/http/http/proxy_user_spec.rb deleted file mode 100644 index 01fda400e9..0000000000 --- a/spec/ruby/library/net/http/http/proxy_user_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.proxy_user" do - describe "when self is no proxy class" do - it "returns nil" do - Net::HTTP.proxy_user.should be_nil - end - end - - describe "when self is a proxy class" do - it "returns nil if no username was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").proxy_user.should be_nil - end - - it "returns the username for self's proxy connection" do - Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks").proxy_user.should == "rspec" - end - end -end - -describe "Net::HTTP#proxy_user" do - describe "when self is no proxy class instance" do - it "returns nil" do - Net::HTTP.new("localhost", 3333).proxy_user.should be_nil - end - end - - describe "when self is a proxy class instance" do - it "returns nil if no username was set for self's proxy connection" do - Net::HTTP.Proxy("localhost").new("localhost", 3333).proxy_user.should be_nil - end - - it "returns the username for self's proxy connection" do - http_with_proxy = Net::HTTP.Proxy("localhost", 1234, "rspec", "rocks") - http_with_proxy.new("localhost", 3333).proxy_user.should == "rspec" - end - end -end diff --git a/spec/ruby/library/net/http/http/put2_spec.rb b/spec/ruby/library/net/http/http/put2_spec.rb deleted file mode 100644 index 99329a5fd9..0000000000 --- a/spec/ruby/library/net/http/http/put2_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_put' - -describe "Net::HTTP#put2" do - it_behaves_like :net_http_request_put, :put2 -end diff --git a/spec/ruby/library/net/http/http/put_spec.rb b/spec/ruby/library/net/http/http/put_spec.rb deleted file mode 100644 index 3ca0d0963e..0000000000 --- a/spec/ruby/library/net/http/http/put_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#put" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends an put request to the passed path and returns the response" do - response = @http.put("/request", "test=test") - response.body.should == "Request type: PUT" - end - - it "returns a Net::HTTPResponse" do - @http.put("/request", "test=test").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/read_timeout_spec.rb b/spec/ruby/library/net/http/http/read_timeout_spec.rb deleted file mode 100644 index e23ee76025..0000000000 --- a/spec/ruby/library/net/http/http/read_timeout_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#read_timeout" do - it "returns the seconds to wait until reading one block" do - net = Net::HTTP.new("localhost") - net.read_timeout.should eql(60) - net.read_timeout = 10 - net.read_timeout.should eql(10) - end -end - -describe "Net::HTTP#read_timeout=" do - it "sets the seconds to wait till the connection is open" do - net = Net::HTTP.new("localhost") - net.read_timeout = 10 - net.read_timeout.should eql(10) - end - - it "returns the newly set value" do - net = Net::HTTP.new("localhost") - (net.read_timeout = 10).should eql(10) - end -end diff --git a/spec/ruby/library/net/http/http/request_get_spec.rb b/spec/ruby/library/net/http/http/request_get_spec.rb deleted file mode 100644 index 9932ef0beb..0000000000 --- a/spec/ruby/library/net/http/http/request_get_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_get' - -describe "Net::HTTP#request_get" do - it_behaves_like :net_http_request_get, :get2 -end diff --git a/spec/ruby/library/net/http/http/request_head_spec.rb b/spec/ruby/library/net/http/http/request_head_spec.rb deleted file mode 100644 index 788101c951..0000000000 --- a/spec/ruby/library/net/http/http/request_head_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_head' - -describe "Net::HTTP#request_head" do - it_behaves_like :net_http_request_head, :request_head -end diff --git a/spec/ruby/library/net/http/http/request_post_spec.rb b/spec/ruby/library/net/http/http/request_post_spec.rb deleted file mode 100644 index 7ac67cf95d..0000000000 --- a/spec/ruby/library/net/http/http/request_post_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_post' - -describe "Net::HTTP#request_post" do - it_behaves_like :net_http_request_post, :request_post -end diff --git a/spec/ruby/library/net/http/http/request_put_spec.rb b/spec/ruby/library/net/http/http/request_put_spec.rb deleted file mode 100644 index 110ac43ca6..0000000000 --- a/spec/ruby/library/net/http/http/request_put_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/request_put' - -describe "Net::HTTP#request_put" do - it_behaves_like :net_http_request_put, :request_put -end diff --git a/spec/ruby/library/net/http/http/request_spec.rb b/spec/ruby/library/net/http/http/request_spec.rb deleted file mode 100644 index e63dde9c8d..0000000000 --- a/spec/ruby/library/net/http/http/request_spec.rb +++ /dev/null @@ -1,109 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#request" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed request_object" do - it "makes a HTTP Request based on the passed request_object" do - response = @http.request(Net::HTTP::Get.new("/request"), "test=test") - response.body.should == "Request type: GET" - - response = @http.request(Net::HTTP::Head.new("/request"), "test=test") - response.body.should be_nil - - response = @http.request(Net::HTTP::Post.new("/request"), "test=test") - response.body.should == "Request type: POST" - - response = @http.request(Net::HTTP::Put.new("/request"), "test=test") - response.body.should == "Request type: PUT" - - response = @http.request(Net::HTTP::Proppatch.new("/request"), "test=test") - response.body.should == "Request type: PROPPATCH" - - response = @http.request(Net::HTTP::Lock.new("/request"), "test=test") - response.body.should == "Request type: LOCK" - - response = @http.request(Net::HTTP::Unlock.new("/request"), "test=test") - response.body.should == "Request type: UNLOCK" - - # TODO: Does not work? - #response = @http.request(Net::HTTP::Options.new("/request"), "test=test") - #response.body.should be_nil - - response = @http.request(Net::HTTP::Propfind.new("/request"), "test=test") - response.body.should == "Request type: PROPFIND" - - response = @http.request(Net::HTTP::Delete.new("/request"), "test=test") - response.body.should == "Request type: DELETE" - - response = @http.request(Net::HTTP::Move.new("/request"), "test=test") - response.body.should == "Request type: MOVE" - - response = @http.request(Net::HTTP::Copy.new("/request"), "test=test") - response.body.should == "Request type: COPY" - - response = @http.request(Net::HTTP::Mkcol.new("/request"), "test=test") - response.body.should == "Request type: MKCOL" - - response = @http.request(Net::HTTP::Trace.new("/request"), "test=test") - response.body.should == "Request type: TRACE" - end - end - - describe "when passed request_object and request_body" do - it "sends the passed request_body when making the HTTP Request" do - response = @http.request(Net::HTTP::Get.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Head.new("/request/body"), "test=test") - response.body.should be_nil - - response = @http.request(Net::HTTP::Post.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Put.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Proppatch.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Lock.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Unlock.new("/request/body"), "test=test") - response.body.should == "test=test" - - # TODO: Does not work? - #response = @http.request(Net::HTTP::Options.new("/request/body"), "test=test") - #response.body.should be_nil - - response = @http.request(Net::HTTP::Propfind.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Delete.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Move.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Copy.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Mkcol.new("/request/body"), "test=test") - response.body.should == "test=test" - - response = @http.request(Net::HTTP::Trace.new("/request/body"), "test=test") - response.body.should == "test=test" - end - end -end diff --git a/spec/ruby/library/net/http/http/request_types_spec.rb b/spec/ruby/library/net/http/http/request_types_spec.rb deleted file mode 100644 index 99d754d3d1..0000000000 --- a/spec/ruby/library/net/http/http/request_types_spec.rb +++ /dev/null @@ -1,254 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP::Get" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Get.should < Net::HTTPRequest - end - - it "represents the 'GET'-Request-Method" do - Net::HTTP::Get::METHOD.should == "GET" - end - - it "has no Request Body" do - Net::HTTP::Get::REQUEST_HAS_BODY.should be_false - end - - it "has a Response Body" do - Net::HTTP::Get::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Head" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Head.should < Net::HTTPRequest - end - - it "represents the 'HEAD'-Request-Method" do - Net::HTTP::Head::METHOD.should == "HEAD" - end - - it "has no Request Body" do - Net::HTTP::Head::REQUEST_HAS_BODY.should be_false - end - - it "has no Response Body" do - Net::HTTP::Head::RESPONSE_HAS_BODY.should be_false - end -end - -describe "Net::HTTP::Post" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Post.should < Net::HTTPRequest - end - - it "represents the 'POST'-Request-Method" do - Net::HTTP::Post::METHOD.should == "POST" - end - - it "has a Request Body" do - Net::HTTP::Post::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Post::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Put" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Put.should < Net::HTTPRequest - end - - it "represents the 'PUT'-Request-Method" do - Net::HTTP::Put::METHOD.should == "PUT" - end - - it "has a Request Body" do - Net::HTTP::Put::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Put::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Delete" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Delete.should < Net::HTTPRequest - end - - it "represents the 'DELETE'-Request-Method" do - Net::HTTP::Delete::METHOD.should == "DELETE" - end - - it "has no Request Body" do - Net::HTTP::Delete::REQUEST_HAS_BODY.should be_false - end - - it "has a Response Body" do - Net::HTTP::Delete::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Options" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Options.should < Net::HTTPRequest - end - - it "represents the 'OPTIONS'-Request-Method" do - Net::HTTP::Options::METHOD.should == "OPTIONS" - end - - it "has no Request Body" do - Net::HTTP::Options::REQUEST_HAS_BODY.should be_false - end - - it "has no Response Body" do - Net::HTTP::Options::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Trace" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Trace.should < Net::HTTPRequest - end - - it "represents the 'TRACE'-Request-Method" do - Net::HTTP::Trace::METHOD.should == "TRACE" - end - - it "has no Request Body" do - Net::HTTP::Trace::REQUEST_HAS_BODY.should be_false - end - - it "has a Response Body" do - Net::HTTP::Trace::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Propfind" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Propfind.should < Net::HTTPRequest - end - - it "represents the 'PROPFIND'-Request-Method" do - Net::HTTP::Propfind::METHOD.should == "PROPFIND" - end - - it "has a Request Body" do - Net::HTTP::Propfind::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Propfind::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Proppatch" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Proppatch.should < Net::HTTPRequest - end - - it "represents the 'PROPPATCH'-Request-Method" do - Net::HTTP::Proppatch::METHOD.should == "PROPPATCH" - end - - it "has a Request Body" do - Net::HTTP::Proppatch::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Proppatch::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Mkcol" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Mkcol.should < Net::HTTPRequest - end - - it "represents the 'MKCOL'-Request-Method" do - Net::HTTP::Mkcol::METHOD.should == "MKCOL" - end - - it "has a Request Body" do - Net::HTTP::Mkcol::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Mkcol::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Copy" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Copy.should < Net::HTTPRequest - end - - it "represents the 'COPY'-Request-Method" do - Net::HTTP::Copy::METHOD.should == "COPY" - end - - it "has no Request Body" do - Net::HTTP::Copy::REQUEST_HAS_BODY.should be_false - end - - it "has a Response Body" do - Net::HTTP::Copy::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Move" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Move.should < Net::HTTPRequest - end - - it "represents the 'MOVE'-Request-Method" do - Net::HTTP::Move::METHOD.should == "MOVE" - end - - it "has no Request Body" do - Net::HTTP::Move::REQUEST_HAS_BODY.should be_false - end - - it "has a Response Body" do - Net::HTTP::Move::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Lock" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Lock.should < Net::HTTPRequest - end - - it "represents the 'LOCK'-Request-Method" do - Net::HTTP::Lock::METHOD.should == "LOCK" - end - - it "has a Request Body" do - Net::HTTP::Lock::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Lock::RESPONSE_HAS_BODY.should be_true - end -end - -describe "Net::HTTP::Unlock" do - it "is a subclass of Net::HTTPRequest" do - Net::HTTP::Unlock.should < Net::HTTPRequest - end - - it "represents the 'UNLOCK'-Request-Method" do - Net::HTTP::Unlock::METHOD.should == "UNLOCK" - end - - it "has a Request Body" do - Net::HTTP::Unlock::REQUEST_HAS_BODY.should be_true - end - - it "has a Response Body" do - Net::HTTP::Unlock::RESPONSE_HAS_BODY.should be_true - end -end diff --git a/spec/ruby/library/net/http/http/send_request_spec.rb b/spec/ruby/library/net/http/http/send_request_spec.rb deleted file mode 100644 index 83e9448b8b..0000000000 --- a/spec/ruby/library/net/http/http/send_request_spec.rb +++ /dev/null @@ -1,61 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#send_request" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - - # HEAD is special so handled separately - @methods = %w[ - GET POST PUT DELETE - OPTIONS - PROPFIND PROPPATCH LOCK UNLOCK - ] - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - # TODO: Does only work with GET and POST requests - describe "when passed type, path" do - it "sends a HTTP Request of the passed type to the passed path" do - response = @http.send_request("HEAD", "/request") - response.body.should be_nil - - (@methods - %w[POST PUT]).each do |method| - response = @http.send_request(method, "/request") - response.body.should == "Request type: #{method}" - end - end - end - - describe "when passed type, path, body" do - it "sends a HTTP Request with the passed body" do - response = @http.send_request("HEAD", "/request/body", "test=test") - response.body.should be_nil - - @methods.each do |method| - response = @http.send_request(method, "/request/body", "test=test") - response.body.should == "test=test" - end - end - end - - describe "when passed type, path, body, headers" do - it "sends a HTTP Request with the passed headers" do - referer = 'https://www.ruby-lang.org/'.freeze - - response = @http.send_request("HEAD", "/request/header", "test=test", "referer" => referer) - response.body.should be_nil - - @methods.each do |method| - response = @http.send_request(method, "/request/header", "test=test", "referer" => referer) - response.body.should include('"Referer"=>"' + referer + '"') - end - end - end -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 deleted file mode 100644 index 94b6f4499d..0000000000 --- a/spec/ruby/library/net/http/http/set_debug_output_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require "stringio" -require_relative 'fixtures/http_server' - -describe "Net::HTTP#set_debug_output when passed io" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.new("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sets the passed io as output stream for debugging" do - io = StringIO.new - - @http.set_debug_output(io) - @http.start - io.string.should_not be_empty - size = io.string.size - - @http.get("/") - io.string.size.should > size - end - - it "outputs a warning when the connection has already been started" do - @http.start - -> { @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/shared/request_get.rb b/spec/ruby/library/net/http/http/shared/request_get.rb deleted file mode 100644 index d25f32049b..0000000000 --- a/spec/ruby/library/net/http/http/shared/request_get.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_get, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a GET request to the passed path and returns the response" do - response = @http.send(@method, "/request") - response.body.should == "Request type: GET" - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a GET request to the passed path and returns the response" do - response = @http.send(@method, "/request") {} - response.body.should == "Request type: GET" - end - - it "yields the response to the passed block" do - @http.send(@method, "/request") do |response| - response.body.should == "Request type: GET" - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net/http/http/shared/request_head.rb b/spec/ruby/library/net/http/http/shared/request_head.rb deleted file mode 100644 index 78b555884b..0000000000 --- a/spec/ruby/library/net/http/http/shared/request_head.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_head, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a head request to the passed path and returns the response" do - response = @http.send(@method, "/request") - response.body.should be_nil - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a head request to the passed path and returns the response" do - response = @http.send(@method, "/request") {} - response.body.should be_nil - end - - it "yields the response to the passed block" do - @http.send(@method, "/request") do |response| - response.body.should be_nil - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net/http/http/shared/request_post.rb b/spec/ruby/library/net/http/http/shared/request_post.rb deleted file mode 100644 index e832411c48..0000000000 --- a/spec/ruby/library/net/http/http/shared/request_post.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_post, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a post request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") - response.body.should == "Request type: POST" - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a post request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") {} - response.body.should == "Request type: POST" - end - - it "yields the response to the passed block" do - @http.send(@method, "/request", "test=test") do |response| - response.body.should == "Request type: POST" - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net/http/http/shared/request_put.rb b/spec/ruby/library/net/http/http/shared/request_put.rb deleted file mode 100644 index 3b902f4957..0000000000 --- a/spec/ruby/library/net/http/http/shared/request_put.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe :net_http_request_put, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - describe "when passed no block" do - it "sends a put request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") - response.body.should == "Request type: PUT" - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") - response.should be_kind_of(Net::HTTPResponse) - end - end - - describe "when passed a block" do - it "sends a put request to the passed path and returns the response" do - response = @http.send(@method, "/request", "test=test") {} - response.body.should == "Request type: PUT" - end - - it "yields the response to the passed block" do - @http.send(@method, "/request", "test=test") do |response| - response.body.should == "Request type: PUT" - end - end - - it "returns a Net::HTTPResponse object" do - response = @http.send(@method, "/request", "test=test") {} - response.should be_kind_of(Net::HTTPResponse) - end - end -end diff --git a/spec/ruby/library/net/http/http/shared/started.rb b/spec/ruby/library/net/http/http/shared/started.rb deleted file mode 100644 index 9ff6272c31..0000000000 --- a/spec/ruby/library/net/http/http/shared/started.rb +++ /dev/null @@ -1,26 +0,0 @@ -describe :net_http_started_p, shared: true do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.new("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "returns true when self has been started" do - @http.start - @http.send(@method).should be_true - end - - it "returns false when self has not been started yet" do - @http.send(@method).should be_false - end - - it "returns false when self has been stopped again" do - @http.start - @http.finish - @http.send(@method).should be_false - end -end diff --git a/spec/ruby/library/net/http/http/shared/version_1_1.rb b/spec/ruby/library/net/http/http/shared/version_1_1.rb deleted file mode 100644 index db3d6a986d..0000000000 --- a/spec/ruby/library/net/http/http/shared/version_1_1.rb +++ /dev/null @@ -1,6 +0,0 @@ -describe :net_http_version_1_1_p, shared: true do - it "returns the state of net/http 1.1 features" do - Net::HTTP.version_1_2 - Net::HTTP.send(@method).should be_false - end -end diff --git a/spec/ruby/library/net/http/http/shared/version_1_2.rb b/spec/ruby/library/net/http/http/shared/version_1_2.rb deleted file mode 100644 index b044182c60..0000000000 --- a/spec/ruby/library/net/http/http/shared/version_1_2.rb +++ /dev/null @@ -1,6 +0,0 @@ -describe :net_http_version_1_2_p, shared: true do - it "returns the state of net/http 1.2 features" do - Net::HTTP.version_1_2 - Net::HTTP.send(@method).should be_true - end -end diff --git a/spec/ruby/library/net/http/http/socket_type_spec.rb b/spec/ruby/library/net/http/http/socket_type_spec.rb deleted file mode 100644 index 5c844ddf94..0000000000 --- a/spec/ruby/library/net/http/http/socket_type_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP.socket_type" do - it "returns BufferedIO" do - Net::HTTP.socket_type.should == Net::BufferedIO - end -end diff --git a/spec/ruby/library/net/http/http/start_spec.rb b/spec/ruby/library/net/http/http/start_spec.rb deleted file mode 100644 index a2768eed18..0000000000 --- a/spec/ruby/library/net/http/http/start_spec.rb +++ /dev/null @@ -1,111 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP.start" do - before :each do - NetHTTPSpecs.start_server - @port = NetHTTPSpecs.port - end - - after :each do - NetHTTPSpecs.stop_server - end - - describe "when not passed a block" do - before :each do - @http = Net::HTTP.start("localhost", @port) - end - - after :each do - @http.finish if @http.started? - end - - it "returns a new Net::HTTP object for the passed address and port" do - @http.should be_kind_of(Net::HTTP) - @http.address.should == "localhost" - @http.port.should == @port - end - - it "opens the tcp connection" do - @http.started?.should be_true - end - end - - describe "when passed a block" do - it "returns the blocks return value" do - Net::HTTP.start("localhost", @port) { :test }.should == :test - end - - it "yields the new Net::HTTP object to the block" do - yielded = false - Net::HTTP.start("localhost", @port) do |net| - yielded = true - net.should be_kind_of(Net::HTTP) - end - yielded.should be_true - end - - it "opens the tcp connection before yielding" do - Net::HTTP.start("localhost", @port) { |http| http.started?.should be_true } - end - - it "closes the tcp connection after yielding" do - net = nil - Net::HTTP.start("localhost", @port) { |x| net = x } - net.started?.should be_false - end - end -end - -describe "Net::HTTP#start" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.new("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "returns self" do - @http.start.should equal(@http) - end - - it "opens the tcp connection" do - @http.start - @http.started?.should be_true - end - - describe "when self has already been started" do - it "raises an IOError" do - @http.start - -> { @http.start }.should raise_error(IOError) - end - end - - describe "when passed a block" do - it "returns the blocks return value" do - @http.start { :test }.should == :test - end - - it "yields the new Net::HTTP object to the block" do - yielded = false - @http.start do |http| - yielded = true - http.should equal(@http) - end - yielded.should be_true - end - - it "opens the tcp connection before yielding" do - @http.start { |http| http.started?.should be_true } - end - - it "closes the tcp connection after yielding" do - @http.start { } - @http.started?.should be_false - end - end -end diff --git a/spec/ruby/library/net/http/http/started_spec.rb b/spec/ruby/library/net/http/http/started_spec.rb deleted file mode 100644 index ea441ed16a..0000000000 --- a/spec/ruby/library/net/http/http/started_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' -require_relative 'shared/started' - -describe "Net::HTTP#started?" do - it_behaves_like :net_http_started_p, :started? -end diff --git a/spec/ruby/library/net/http/http/trace_spec.rb b/spec/ruby/library/net/http/http/trace_spec.rb deleted file mode 100644 index 94a1bf6655..0000000000 --- a/spec/ruby/library/net/http/http/trace_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#trace" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends a TRACE request to the passed path and returns the response" do - response = @http.trace("/request") - response.body.should == "Request type: TRACE" - end - - it "returns a Net::HTTPResponse" do - @http.trace("/request").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/unlock_spec.rb b/spec/ruby/library/net/http/http/unlock_spec.rb deleted file mode 100644 index a4f1b7a1d1..0000000000 --- a/spec/ruby/library/net/http/http/unlock_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/http_server' - -describe "Net::HTTP#unlock" do - before :each do - NetHTTPSpecs.start_server - @http = Net::HTTP.start("localhost", NetHTTPSpecs.port) - end - - after :each do - @http.finish if @http.started? - NetHTTPSpecs.stop_server - end - - it "sends an UNLOCK request to the passed path and returns the response" do - response = @http.unlock("/request", "test=test") - response.body.should == "Request type: UNLOCK" - end - - it "returns a Net::HTTPResponse" do - @http.unlock("/request", "test=test").should be_kind_of(Net::HTTPResponse) - end -end diff --git a/spec/ruby/library/net/http/http/use_ssl_spec.rb b/spec/ruby/library/net/http/http/use_ssl_spec.rb deleted file mode 100644 index be1ec7fa25..0000000000 --- a/spec/ruby/library/net/http/http/use_ssl_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTP#use_ssl?" do - it "returns false" do - http = Net::HTTP.new("localhost") - http.use_ssl?.should be_false - end -end diff --git a/spec/ruby/library/net/http/http/version_1_1_spec.rb b/spec/ruby/library/net/http/http/version_1_1_spec.rb deleted file mode 100644 index 1c069e9ea6..0000000000 --- a/spec/ruby/library/net/http/http/version_1_1_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'shared/version_1_1' - -describe "Net::HTTP.version_1_1?" do - it_behaves_like :net_http_version_1_1_p, :version_1_1? -end diff --git a/spec/ruby/library/net/http/http/version_1_2_spec.rb b/spec/ruby/library/net/http/http/version_1_2_spec.rb deleted file mode 100644 index 4e601462c9..0000000000 --- a/spec/ruby/library/net/http/http/version_1_2_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'shared/version_1_2' - -describe "Net::HTTP.version_1_2" do - it "turns on net/http 1.2 features" do - Net::HTTP.version_1_2 - - Net::HTTP.version_1_2?.should be_true - Net::HTTP.version_1_1?.should be_false - end - - it "returns true" do - Net::HTTP.version_1_2.should be_true - end -end - -describe "Net::HTTP.version_1_2?" do - it_behaves_like :net_http_version_1_2_p, :version_1_2? -end diff --git a/spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb b/spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb deleted file mode 100644 index abe8855eff..0000000000 --- a/spec/ruby/library/net/http/httpexceptions/fixtures/classes.rb +++ /dev/null @@ -1,5 +0,0 @@ -module NetHTTPExceptionsSpecs - class Simple < StandardError - include Net::HTTPExceptions - end -end diff --git a/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb b/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb deleted file mode 100644 index 8e3fd8cc02..0000000000 --- a/spec/ruby/library/net/http/httpexceptions/initialize_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPExceptions#initialize when passed message, response" do - before :each do - @exception = NetHTTPExceptionsSpecs::Simple.new("error message", "a http response") - end - - it "calls super with the passed message" do - @exception.message.should == "error message" - end - - it "sets self's response to the passed response" do - @exception.response.should == "a http response" - end -end diff --git a/spec/ruby/library/net/http/httpexceptions/response_spec.rb b/spec/ruby/library/net/http/httpexceptions/response_spec.rb deleted file mode 100644 index 205b2bc212..0000000000 --- a/spec/ruby/library/net/http/httpexceptions/response_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPExceptions#response" do - it "returns self's response" do - exception = NetHTTPExceptionsSpecs::Simple.new("error message", "a http response") - exception.response.should == "a http response" - 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 deleted file mode 100644 index 7d081939b8..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/body_exist_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#body_exist?" do - it "returns true when the response is expected to have a body" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body_exist?.should be_true - - request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - request.body_exist?.should be_false - end - - describe "when $VERBOSE is true" do - it "emits a warning" do - request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - -> { - request.body_exist? - }.should complain(/body_exist\? is obsolete/, verbose: true) - end - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb deleted file mode 100644 index a215895b57..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/body_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require "stringio" - -describe "Net::HTTPGenericRequest#body" do - it "returns self's request body" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body.should be_nil - - request.body = "Some Content" - request.body.should == "Some Content" - end -end - -describe "Net::HTTPGenericRequest#body=" do - before :each do - @request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - end - - it "sets self's body content to the passed String" do - @request.body = "Some Content" - @request.body.should == "Some Content" - end - - it "sets self's body stream to nil" do - @request.body_stream = StringIO.new("") - @request.body = "Some Content" - @request.body_stream.should be_nil - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb deleted file mode 100644 index c2a60e6836..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/body_stream_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require "stringio" - -describe "Net::HTTPGenericRequest#body_stream" do - it "returns self's body stream Object" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body_stream.should be_nil - - stream = StringIO.new("test") - request.body_stream = stream - request.body_stream.should equal(stream) - end -end - -describe "Net::HTTPGenericRequest#body_stream=" do - before :each do - @request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - @stream = StringIO.new("test") - end - - it "sets self's body stream to the passed Object" do - @request.body_stream = @stream - @request.body_stream.should equal(@stream) - end - - it "sets self's body to nil" do - @request.body = "Some Content" - @request.body_stream = @stream - @request.body.should be_nil - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb deleted file mode 100644 index da5b1a63be..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/exec_spec.rb +++ /dev/null @@ -1,131 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require "stringio" - -describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do - before :each do - @socket = StringIO.new("") - @buffered_socket = Net::BufferedIO.new(@socket) - end - - it "executes the request over the socket to the path using the HTTP version" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - - request.exec(@buffered_socket, "1.1", "/some/path") - str = @socket.string - - str.should =~ %r[POST /some/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str[-4..-1].should == "\r\n\r\n" - - request = Net::HTTPGenericRequest.new("GET", true, true, "/some/path", - "Content-Type" => "text/html") - - request.exec(@buffered_socket, "1.0", "/some/other/path") - str = @socket.string - - str.should =~ %r[GET /some/other/path HTTP/1.0\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: text/html\r\n] - str[-4..-1].should == "\r\n\r\n" - end - - describe "when a request body is set" do - it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.body = "Some Content" - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] - str.should =~ %r[Content-Length: 12\r\n] - str[-16..-1].should == "\r\n\r\nSome Content" - end - - it "correctly sets the 'Content-Length' header and includes the body" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", - "Content-Type" => "text/html") - request.body = "Some Content" - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: text/html\r\n] - str.should =~ %r[Content-Length: 12\r\n] - str[-16..-1].should == "\r\n\r\nSome Content" - end - end - - describe "when a body stream is set" do - it "sets the 'Content-Type' header to 'application/x-www-form-urlencoded' unless the 'Content-Type' header is supplied" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", - "Content-Length" => "10") - request.body_stream = StringIO.new("a" * 20) - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: application/x-www-form-urlencoded\r\n] - str.should =~ %r[Content-Length: 10\r\n] - str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa" - end - - it "sends the whole stream, regardless of the 'Content-Length' header" do - request = Net::HTTPGenericRequest.new("POST", true, true,"/some/path", - "Content-Type" => "text/html", - "Content-Length" => "10") - request.body_stream = StringIO.new("a" * 20) - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: text/html\r\n] - str.should =~ %r[Content-Length: 10\r\n] - str[-24..-1].should == "\r\n\r\naaaaaaaaaaaaaaaaaaaa" - end - - it "sends the request in chunks when 'Transfer-Encoding' is set to 'chunked'" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", - "Content-Type" => "text/html", - "Transfer-Encoding" => "chunked") - datasize = 1024 * 10 - request.body_stream = StringIO.new("a" * datasize) - - request.exec(@buffered_socket, "1.1", "/some/other/path") - str = @socket.string - - str.should =~ %r[POST /some/other/path HTTP/1.1\r\n] - str.should =~ %r[Accept: \*/\*\r\n] - str.should =~ %r[Content-Type: text/html\r\n] - str.should =~ %r[Transfer-Encoding: chunked\r\n] - str =~ %r[\r\n\r\n] - str = $' - while datasize > 0 - chunk_size_line, str = str.split(/\r\n/, 2) - chunk_size = chunk_size_line[/\A[0-9A-Fa-f]+/].to_i(16) - str.slice!(0, chunk_size).should == 'a' * chunk_size - datasize -= chunk_size - str.slice!(0, 2).should == "\r\n" - end - datasize.should == 0 - str.should == %"0\r\n\r\n" - end - - it "raises an ArgumentError when the 'Content-Length' is not set or 'Transfer-Encoding' is not set to 'chunked'" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path", - "Content-Type" => "text/html") - request.body_stream = StringIO.new("Some Content") - - -> { 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/inspect_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb deleted file mode 100644 index 36240949c3..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/inspect_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#inspect" do - it "returns a String representation of self" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.inspect.should == "#<Net::HTTPGenericRequest POST>" - - request = Net::HTTPGenericRequest.new("GET", false, true, "/some/path") - request.inspect.should == "#<Net::HTTPGenericRequest GET>" - - request = Net::HTTPGenericRequest.new("BLA", true, true, "/some/path") - request.inspect.should == "#<Net::HTTPGenericRequest BLA>" - - # Subclasses - request = Net::HTTP::Get.new("/some/path") - request.inspect.should == "#<Net::HTTP::Get GET>" - - request = Net::HTTP::Post.new("/some/path") - request.inspect.should == "#<Net::HTTP::Post POST>" - - request = Net::HTTP::Trace.new("/some/path") - request.inspect.should == "#<Net::HTTP::Trace TRACE>" - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb deleted file mode 100644 index 3f7c2cbf2b..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/method_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#method" do - it "returns self's request method" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.method.should == "POST" - - request = Net::HTTPGenericRequest.new("GET", false, true, "/some/path") - request.method.should == "GET" - - request = Net::HTTPGenericRequest.new("BLA", true, true, "/some/path") - request.method.should == "BLA" - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb deleted file mode 100644 index fc4cf9af53..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/path_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#path" do - it "returns self's request path" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.path.should == "/some/path" - - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/other/path") - request.path.should == "/some/other/path" - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb deleted file mode 100644 index 50cd1ff637..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/request_body_permitted_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#request_body_permitted?" do - it "returns true when the request is expected to have a body" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.request_body_permitted?.should be_true - - request = Net::HTTPGenericRequest.new("POST", false, true, "/some/path") - request.request_body_permitted?.should be_false - end -end diff --git a/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb b/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb deleted file mode 100644 index 0c4165d0ab..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/response_body_permitted_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#response_body_permitted?" do - it "returns true when the response is expected to have a body" do - request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - request.response_body_permitted?.should be_true - - request = Net::HTTPGenericRequest.new("POST", true, false, "/some/path") - request.response_body_permitted?.should be_false - 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 deleted file mode 100644 index 7494c69173..0000000000 --- a/spec/ruby/library/net/http/httpgenericrequest/set_body_internal_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPGenericRequest#set_body_internal when passed string" do - before :each do - @request = Net::HTTPGenericRequest.new("POST", true, true, "/some/path") - end - - it "sets self's body to the passed string" do - @request.set_body_internal("Some Content") - @request.body.should == "Some Content" - end - - it "raises an ArgumentError when the body or body_stream of self have already been set" do - @request.body = "Some Content" - -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) - - @request.body_stream = "Some Content" - -> { @request.set_body_internal("Some other Content") }.should raise_error(ArgumentError) - end -end diff --git a/spec/ruby/library/net/http/httpheader/add_field_spec.rb b/spec/ruby/library/net/http/httpheader/add_field_spec.rb deleted file mode 100644 index 882d5ac5bb..0000000000 --- a/spec/ruby/library/net/http/httpheader/add_field_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#add_field when passed key, value" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "adds the passed value to the header entry with the passed key" do - @headers.add_field("My-Header", "a") - @headers.get_fields("My-Header").should == ["a"] - - @headers.add_field("My-Header", "b") - @headers.get_fields("My-Header").should == ["a", "b"] - - @headers.add_field("My-Header", "c") - @headers.get_fields("My-Header").should == ["a", "b", "c"] - end - - it "is case-insensitive" do - @headers.add_field("My-Header", "a") - @headers.get_fields("My-Header").should == ["a"] - - @headers.add_field("my-header", "b") - @headers.get_fields("My-Header").should == ["a", "b"] - - @headers.add_field("MY-HEADER", "c") - @headers.get_fields("My-Header").should == ["a", "b", "c"] - end -end diff --git a/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb b/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb deleted file mode 100644 index fa2a710fe1..0000000000 --- a/spec/ruby/library/net/http/httpheader/basic_auth_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#basic_auth when passed account, password" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "sets the 'Authorization' Header entry for basic authorization" do - @headers.basic_auth("rubyspec", "rocks") - @headers["Authorization"].should == "Basic cnVieXNwZWM6cm9ja3M=" - end -end diff --git a/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb b/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb deleted file mode 100644 index 0dddd3049b..0000000000 --- a/spec/ruby/library/net/http/httpheader/canonical_each_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_capitalized' - -describe "Net::HTTPHeader#canonical_each" do - it_behaves_like :net_httpheader_each_capitalized, :canonical_each -end diff --git a/spec/ruby/library/net/http/httpheader/chunked_spec.rb b/spec/ruby/library/net/http/httpheader/chunked_spec.rb deleted file mode 100644 index 96b758981b..0000000000 --- a/spec/ruby/library/net/http/httpheader/chunked_spec.rb +++ /dev/null @@ -1,22 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#chunked?" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns true if the 'Transfer-Encoding' header entry is set to chunked" do - @headers.chunked?.should be_false - - @headers["Transfer-Encoding"] = "bla" - @headers.chunked?.should be_false - - @headers["Transfer-Encoding"] = "blachunkedbla" - @headers.chunked?.should be_false - - @headers["Transfer-Encoding"] = "chunked" - @headers.chunked?.should be_true - 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 deleted file mode 100644 index e344817e82..0000000000 --- a/spec/ruby/library/net/http/httpheader/content_length_spec.rb +++ /dev/null @@ -1,54 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#content_length" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns nil if no 'Content-Length' header entry is set" do - @headers.content_length.should be_nil - end - - it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Length' header entry has an invalid format" do - @headers["Content-Length"] = "invalid" - -> { @headers.content_length }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "returns the value of the 'Content-Length' header entry as an Integer" do - @headers["Content-Length"] = "123" - @headers.content_length.should eql(123) - - @headers["Content-Length"] = "123valid" - @headers.content_length.should eql(123) - - @headers["Content-Length"] = "valid123" - @headers.content_length.should eql(123) - end -end - -describe "Net::HTTPHeader#content_length=" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "removes the 'Content-Length' entry if passed false or nil" do - @headers["Content-Length"] = "123" - @headers.content_length = nil - @headers["Content-Length"].should be_nil - end - - it "sets the 'Content-Length' entry to the passed value" do - @headers.content_length = "123" - @headers["Content-Length"].should == "123" - - @headers.content_length = "123valid" - @headers["Content-Length"].should == "123" - end - - it "sets the 'Content-Length' entry to 0 if the passed value is not valid" do - @headers.content_length = "invalid123" - @headers["Content-Length"].should == "0" - end -end diff --git a/spec/ruby/library/net/http/httpheader/content_range_spec.rb b/spec/ruby/library/net/http/httpheader/content_range_spec.rb deleted file mode 100644 index ba75f9a9a1..0000000000 --- a/spec/ruby/library/net/http/httpheader/content_range_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#content_range" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns a Range object that represents the 'Content-Range' header entry" do - @headers["Content-Range"] = "bytes 0-499/1234" - @headers.content_range.should == (0..499) - - @headers["Content-Range"] = "bytes 500-1233/1234" - @headers.content_range.should == (500..1233) - end - - it "returns nil when there is no 'Content-Range' header entry" do - @headers.content_range.should be_nil - end - - it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do - @headers["Content-Range"] = "invalid" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) - - @headers["Content-Range"] = "bytes 123-abc" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) - - @headers["Content-Range"] = "bytes abc-123" - -> { @headers.content_range }.should raise_error(Net::HTTPHeaderSyntaxError) - end -end diff --git a/spec/ruby/library/net/http/httpheader/content_type_spec.rb b/spec/ruby/library/net/http/httpheader/content_type_spec.rb deleted file mode 100644 index 1f8b4ba326..0000000000 --- a/spec/ruby/library/net/http/httpheader/content_type_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/set_content_type' - -describe "Net::HTTPHeader#content_type" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the content type string, as per 'Content-Type' header entry" do - @headers["Content-Type"] = "text/html" - @headers.content_type.should == "text/html" - - @headers["Content-Type"] = "text/html;charset=utf-8" - @headers.content_type.should == "text/html" - end - - it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.content_type.should be_nil - end -end - -describe "Net::HTTPHeader#content_type=" do - it_behaves_like :net_httpheader_set_content_type, :content_type= -end diff --git a/spec/ruby/library/net/http/httpheader/delete_spec.rb b/spec/ruby/library/net/http/httpheader/delete_spec.rb deleted file mode 100644 index 603ae198de..0000000000 --- a/spec/ruby/library/net/http/httpheader/delete_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#delete when passed key" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "removes the header entry with the passed key" do - @headers["My-Header"] = "test" - @headers.delete("My-Header") - - @headers["My-Header"].should be_nil - @headers.size.should eql(0) - end - - it "returns the removed values" do - @headers["My-Header"] = "test" - @headers.delete("My-Header").should == ["test"] - end - - it "is case-insensitive" do - @headers["My-Header"] = "test" - @headers.delete("my-header") - - @headers["My-Header"].should be_nil - @headers.size.should eql(0) - end -end diff --git a/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb b/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb deleted file mode 100644 index 1af2c6939c..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_capitalized_name_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#each_capitalized_name" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["My-Header"] = "test" - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - end - - describe "when passed a block" do - it "yields each header key to the passed block (keys capitalized)" do - res = [] - @headers.each_capitalized_name do |key| - res << key - end - res.sort.should == ["My-Header", "My-Other-Header"] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.each_capitalized_name - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |key| - res << key - end - res.sort.should == ["My-Header", "My-Other-Header"] - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb b/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb deleted file mode 100644 index 961a2d051f..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_capitalized_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_capitalized' - -describe "Net::HTTPHeader#each_capitalized" do - it_behaves_like :net_httpheader_each_capitalized, :each_capitalized -end diff --git a/spec/ruby/library/net/http/httpheader/each_header_spec.rb b/spec/ruby/library/net/http/httpheader/each_header_spec.rb deleted file mode 100644 index 19634a001b..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_header_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_header' - -describe "Net::HTTPHeader#each_header" do - it_behaves_like :net_httpheader_each_header, :each_header -end diff --git a/spec/ruby/library/net/http/httpheader/each_key_spec.rb b/spec/ruby/library/net/http/httpheader/each_key_spec.rb deleted file mode 100644 index ebb17d2eac..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_key_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_name' - -describe "Net::HTTPHeader#each_key" do - it_behaves_like :net_httpheader_each_name, :each_key -end diff --git a/spec/ruby/library/net/http/httpheader/each_name_spec.rb b/spec/ruby/library/net/http/httpheader/each_name_spec.rb deleted file mode 100644 index f4533ebcfb..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_name_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_name' - -describe "Net::HTTPHeader#each_name" do - it_behaves_like :net_httpheader_each_name, :each_name -end diff --git a/spec/ruby/library/net/http/httpheader/each_spec.rb b/spec/ruby/library/net/http/httpheader/each_spec.rb deleted file mode 100644 index 7ba8434f75..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/each_header' - -describe "Net::HTTPHeader#each" do - it_behaves_like :net_httpheader_each_header, :each -end diff --git a/spec/ruby/library/net/http/httpheader/each_value_spec.rb b/spec/ruby/library/net/http/httpheader/each_value_spec.rb deleted file mode 100644 index 3224de7703..0000000000 --- a/spec/ruby/library/net/http/httpheader/each_value_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#each_value" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["My-Header"] = "test" - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - end - - describe "when passed a block" do - it "yields each header entry's joined values" do - res = [] - @headers.each_value do |value| - res << value - end - res.sort.should == ["a, b", "test"] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.each_value - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |key| - res << key - end - res.sort.should == ["a, b", "test"] - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/element_reference_spec.rb b/spec/ruby/library/net/http/httpheader/element_reference_spec.rb deleted file mode 100644 index 4a35e20d20..0000000000 --- a/spec/ruby/library/net/http/httpheader/element_reference_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#[] when passed key" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the value of the header entry with the passed key" do - @headers["My-Header"] = "test" - @headers["My-Header"].should == "test" - @headers["My-Other-Header"] = "another test" - @headers["My-Other-Header"].should == "another test" - end - - it "is case-insensitive" do - @headers["My-Header"] = "test" - - @headers['My-Header'].should == "test" - @headers['my-Header'].should == "test" - @headers['My-header'].should == "test" - @headers['my-header'].should == "test" - @headers['MY-HEADER'].should == "test" - end - - it "returns multi-element values joined together" do - @headers["My-Header"] = "test" - @headers.add_field("My-Header", "another test") - @headers.add_field("My-Header", "and one more") - - @headers["My-Header"].should == "test, another test, and one more" - end - - it "returns nil for non-existing entries" do - @headers["My-Header"].should be_nil - @headers["My-Other-Header"].should be_nil - end -end diff --git a/spec/ruby/library/net/http/httpheader/element_set_spec.rb b/spec/ruby/library/net/http/httpheader/element_set_spec.rb deleted file mode 100644 index e9ad64fafc..0000000000 --- a/spec/ruby/library/net/http/httpheader/element_set_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#[]= when passed key, value" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "sets the header entry with the passed key to the passed value" do - @headers["My-Header"] = "test" - @headers["My-Header"].should == "test" - - @headers["My-Header"] = "overwritten" - @headers["My-Header"].should == "overwritten" - - @headers["My-Other-Header"] = "another test" - @headers["My-Other-Header"].should == "another test" - end - - it "is case-insensitive" do - @headers['My-Header'] = "test" - @headers['my-Header'] = "another test" - @headers['My-header'] = "and one more test" - @headers['my-header'] = "and another one" - @headers['MY-HEADER'] = "last one" - - @headers["My-Header"].should == "last one" - @headers.size.should eql(1) - end - - it "removes the header entry with the passed key when the value is false or nil" do - @headers['My-Header'] = "test" - @headers['My-Header'] = nil - @headers['My-Header'].should be_nil - - @headers['My-Header'] = "test" - @headers['My-Header'] = false - @headers['My-Header'].should be_nil - end -end diff --git a/spec/ruby/library/net/http/httpheader/fetch_spec.rb b/spec/ruby/library/net/http/httpheader/fetch_spec.rb deleted file mode 100644 index ea15679acb..0000000000 --- a/spec/ruby/library/net/http/httpheader/fetch_spec.rb +++ /dev/null @@ -1,68 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#fetch" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - describe "when passed key" do - it "returns the header entry for the passed key" do - @headers["My-Header"] = "test" - @headers.fetch("My-Header").should == "test" - - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - @headers.add_field("My-Other-Header", "c") - @headers.fetch("My-Other-Header").should == "a, b, c" - end - - it "is case-insensitive" do - @headers["My-Header"] = "test" - @headers.fetch("my-header").should == "test" - @headers.fetch("MY-HEADER").should == "test" - end - - it "returns nil when there is no entry for the passed key" do - -> { @headers.fetch("my-header") }.should raise_error(IndexError) - end - end - - describe "when passed key, default" do - it "returns the header entry for the passed key" do - @headers["My-Header"] = "test" - @headers.fetch("My-Header", "bla").should == "test" - - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - @headers.add_field("My-Other-Header", "c") - @headers.fetch("My-Other-Header", "bla").should == "a, b, c" - end - - # TODO: This raises a NoMethodError: undefined method `join' for "bla":String - it "returns the default value when there is no entry for the passed key" do - @headers.fetch("My-Header", "bla").should == "bla" - end - end - - describe "when passed key and block" do - it "returns the header entry for the passed key" do - @headers["My-Header"] = "test" - @headers.fetch("My-Header") {}.should == "test" - - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - @headers.add_field("My-Other-Header", "c") - -> { - @result = @headers.fetch("My-Other-Header", "bla") {} - }.should complain(/block supersedes default value argument/) - @result.should == "a, b, c" - end - - # TODO: This raises a NoMethodError: undefined method `join' for "redaeh-ym":String - it "yieldsand returns the block's return value when there is no entry for the passed key" do - @headers.fetch("My-Header") { |key| key.reverse }.should == "redaeh-ym" - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/fixtures/classes.rb b/spec/ruby/library/net/http/httpheader/fixtures/classes.rb deleted file mode 100644 index b5ec6abd75..0000000000 --- a/spec/ruby/library/net/http/httpheader/fixtures/classes.rb +++ /dev/null @@ -1,11 +0,0 @@ -module NetHTTPHeaderSpecs - class Example - include Net::HTTPHeader - - attr_accessor :body - - def initialize - initialize_http_header({}) - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/form_data_spec.rb b/spec/ruby/library/net/http/httpheader/form_data_spec.rb deleted file mode 100644 index 9b29a03159..0000000000 --- a/spec/ruby/library/net/http/httpheader/form_data_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/set_form_data' - -describe "Net::HTTPHeader#form_data=" do - it_behaves_like :net_httpheader_set_form_data, :form_data= -end diff --git a/spec/ruby/library/net/http/httpheader/get_fields_spec.rb b/spec/ruby/library/net/http/httpheader/get_fields_spec.rb deleted file mode 100644 index 1b623bf2a3..0000000000 --- a/spec/ruby/library/net/http/httpheader/get_fields_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#get_fields when passed key" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns an Array containing the values of the header entry with the passed key" do - @headers["My-Header"] = "a" - @headers.get_fields("My-Header").should == ["a"] - - @headers.add_field("My-Header", "b") - @headers.get_fields("My-Header").should == ["a", "b"] - end - - it "returns a copy of the header entry values" do - @headers["My-Header"] = "a" - - @headers.get_fields("My-Header").clear - @headers.get_fields("My-Header").should == ["a"] - - @headers.get_fields("My-Header") << "b" - @headers.get_fields("My-Header").should == ["a"] - end - - it "returns nil for non-existing header entries" do - @headers.get_fields("My-Header").should be_nil - @headers.get_fields("My-Other-header").should be_nil - end - - it "is case-insensitive" do - @headers["My-Header"] = "test" - @headers.get_fields("My-Header").should == ["test"] - @headers.get_fields("my-header").should == ["test"] - @headers.get_fields("MY-HEADER").should == ["test"] - 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 deleted file mode 100644 index efc5e7d0b2..0000000000 --- a/spec/ruby/library/net/http/httpheader/initialize_http_header_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#initialize_http_header when passed Hash" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.allocate - end - - it "initializes the HTTP Header using the passed Hash" do - @headers.initialize_http_header("My-Header" => "test", "My-Other-Header" => "another test") - @headers["My-Header"].should == "test" - @headers["My-Other-Header"].should == "another test" - end - - it "complains about duplicate keys when in verbose mode" do - -> do - @headers.initialize_http_header("My-Header" => "test", "my-header" => "another test") - end.should complain(/duplicated HTTP header/, verbose: true) - end -end diff --git a/spec/ruby/library/net/http/httpheader/key_spec.rb b/spec/ruby/library/net/http/httpheader/key_spec.rb deleted file mode 100644 index 9099024229..0000000000 --- a/spec/ruby/library/net/http/httpheader/key_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#key? when passed key" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns true if the header entry with the passed key exists" do - @headers.key?("My-Header").should be_false - @headers["My-Header"] = "test" - @headers.key?("My-Header").should be_true - end - - it "is case-insensitive" do - @headers["My-Header"] = "test" - @headers.key?("my-header").should be_true - @headers.key?("MY-HEADER").should be_true - end -end diff --git a/spec/ruby/library/net/http/httpheader/length_spec.rb b/spec/ruby/library/net/http/httpheader/length_spec.rb deleted file mode 100644 index 0d1da149f4..0000000000 --- a/spec/ruby/library/net/http/httpheader/length_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/size' - -describe "Net::HTTPHeader#length" do - it_behaves_like :net_httpheader_size, :length -end diff --git a/spec/ruby/library/net/http/httpheader/main_type_spec.rb b/spec/ruby/library/net/http/httpheader/main_type_spec.rb deleted file mode 100644 index 3e18de6b5b..0000000000 --- a/spec/ruby/library/net/http/httpheader/main_type_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#main_type" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the 'main-content-type', as per 'Content-Type' header entry" do - @headers["Content-Type"] = "text/html" - @headers.main_type.should == "text" - - @headers["Content-Type"] = "application/pdf" - @headers.main_type.should == "application" - - @headers["Content-Type"] = "text/html;charset=utf-8" - @headers.main_type.should == "text" - end - - it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.main_type.should be_nil - end -end diff --git a/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb b/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb deleted file mode 100644 index 8b576ee164..0000000000 --- a/spec/ruby/library/net/http/httpheader/proxy_basic_auth_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#proxy_basic_auth when passed account, password" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "sets the 'Proxy-Authorization' Header entry for basic authorization" do - @headers.proxy_basic_auth("rubyspec", "rocks") - @headers["Proxy-Authorization"].should == "Basic cnVieXNwZWM6cm9ja3M=" - end -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 deleted file mode 100644 index b8fce4f690..0000000000 --- a/spec/ruby/library/net/http/httpheader/range_length_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#range_length" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the length of the Range represented by the 'Content-Range' header entry" do - @headers["Content-Range"] = "bytes 0-499/1234" - @headers.range_length.should eql(500) - - @headers["Content-Range"] = "bytes 500-1233/1234" - @headers.range_length.should eql(734) - end - - it "returns nil when there is no 'Content-Range' header entry" do - @headers.range_length.should be_nil - end - - it "raises a Net::HTTPHeaderSyntaxError when the 'Content-Range' has an invalid format" do - @headers["Content-Range"] = "invalid" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) - - @headers["Content-Range"] = "bytes 123-abc" - -> { @headers.range_length }.should raise_error(Net::HTTPHeaderSyntaxError) - - @headers["Content-Range"] = "bytes abc-123" - -> { @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 deleted file mode 100644 index 005177f6be..0000000000 --- a/spec/ruby/library/net/http/httpheader/range_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/set_range' - -describe "Net::HTTPHeader#range" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns a Range object that represents the 'Range' header entry" do - @headers["Range"] = "bytes=0-499" - @headers.range.should == [0..499] - - @headers["Range"] = "bytes=500-1233" - @headers.range.should == [500..1233] - - @headers["Range"] = "bytes=10-" - @headers.range.should == [10..-1] - - @headers["Range"] = "bytes=-10" - @headers.range.should == [-10..-1] - end - - it "returns nil when there is no 'Range' header entry" do - @headers.range.should be_nil - end - - it "raises a Net::HTTPHeaderSyntaxError when the 'Range' has an invalid format" do - @headers["Range"] = "invalid" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) - - @headers["Range"] = "bytes 123-abc" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) - - @headers["Range"] = "bytes abc-123" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when the 'Range' was not specified" do - @headers["Range"] = "bytes=-" - -> { @headers.range }.should raise_error(Net::HTTPHeaderSyntaxError) - end -end - -describe "Net::HTTPHeader#range=" do - it_behaves_like :net_httpheader_set_range, :range= -end diff --git a/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb b/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb deleted file mode 100644 index 125f7a7e0d..0000000000 --- a/spec/ruby/library/net/http/httpheader/set_content_type_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/set_content_type' - -describe "Net::HTTPHeader#set_content_type" do - it_behaves_like :net_httpheader_set_content_type, :set_content_type -end diff --git a/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb b/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb deleted file mode 100644 index 14c66ae01c..0000000000 --- a/spec/ruby/library/net/http/httpheader/set_form_data_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/set_form_data' - -describe "Net::HTTPHeader#set_form_data" do - it_behaves_like :net_httpheader_set_form_data, :set_form_data -end diff --git a/spec/ruby/library/net/http/httpheader/set_range_spec.rb b/spec/ruby/library/net/http/httpheader/set_range_spec.rb deleted file mode 100644 index 85b9c50422..0000000000 --- a/spec/ruby/library/net/http/httpheader/set_range_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/set_range' - -describe "Net::HTTPHeader#set_range" do - it_behaves_like :net_httpheader_set_range, :set_range -end diff --git a/spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb b/spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb deleted file mode 100644 index 3bac409876..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/each_capitalized.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :net_httpheader_each_capitalized, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["my-header"] = "test" - @headers.add_field("my-Other-Header", "a") - @headers.add_field("My-Other-header", "b") - end - - describe "when passed a block" do - it "yields each header entry to the passed block (capitalized keys, values joined)" do - res = [] - @headers.send(@method) do |key, value| - res << [key, value] - end - res.sort.should == [["My-Header", "test"], ["My-Other-Header", "a, b"]] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |*key| - res << key - end - res.sort.should == [["My-Header", "test"], ["My-Other-Header", "a, b"]] - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/shared/each_header.rb b/spec/ruby/library/net/http/httpheader/shared/each_header.rb deleted file mode 100644 index 6bf3a6ddfe..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/each_header.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :net_httpheader_each_header, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["My-Header"] = "test" - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - end - - describe "when passed a block" do - it "yields each header entry to the passed block (keys in lower case, values joined)" do - res = [] - @headers.send(@method) do |key, value| - res << [key, value] - end - res.sort.should == [["my-header", "test"], ["my-other-header", "a, b"]] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |*key| - res << key - end - res.sort.should == [["my-header", "test"], ["my-other-header", "a, b"]] - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/shared/each_name.rb b/spec/ruby/library/net/http/httpheader/shared/each_name.rb deleted file mode 100644 index efc6a09dfd..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/each_name.rb +++ /dev/null @@ -1,31 +0,0 @@ -describe :net_httpheader_each_name, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - @headers["My-Header"] = "test" - @headers.add_field("My-Other-Header", "a") - @headers.add_field("My-Other-Header", "b") - end - - describe "when passed a block" do - it "yields each header key to the passed block (keys in lower case)" do - res = [] - @headers.send(@method) do |key| - res << key - end - res.sort.should == ["my-header", "my-other-header"] - end - end - - describe "when passed no block" do - it "returns an Enumerator" do - enumerator = @headers.send(@method) - enumerator.should be_an_instance_of(Enumerator) - - res = [] - enumerator.each do |key| - res << key - end - res.sort.should == ["my-header", "my-other-header"] - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/shared/set_content_type.rb b/spec/ruby/library/net/http/httpheader/shared/set_content_type.rb deleted file mode 100644 index b7359bdca6..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/set_content_type.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe :net_httpheader_set_content_type, shared: true do - describe "when passed type, params" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "sets the 'Content-Type' header entry based on the passed type and params" do - @headers.send(@method, "text/html") - @headers["Content-Type"].should == "text/html" - - @headers.send(@method, "text/html", "charset" => "utf-8") - @headers["Content-Type"].should == "text/html; charset=utf-8" - - @headers.send(@method, "text/html", "charset" => "utf-8", "rubyspec" => "rocks") - @headers["Content-Type"].split(/; /).sort.should == %w[charset=utf-8 rubyspec=rocks text/html] - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/shared/set_form_data.rb b/spec/ruby/library/net/http/httpheader/shared/set_form_data.rb deleted file mode 100644 index db20b18803..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/set_form_data.rb +++ /dev/null @@ -1,27 +0,0 @@ -describe :net_httpheader_set_form_data, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - describe "when passed params" do - it "automatically set the 'Content-Type' to 'application/x-www-form-urlencoded'" do - @headers.send(@method, "cmd" => "search", "q" => "ruby", "max" => "50") - @headers["Content-Type"].should == "application/x-www-form-urlencoded" - end - - it "sets self's body based on the passed form parameters" do - @headers.send(@method, "cmd" => "search", "q" => "ruby", "max" => "50") - @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"] - end - end - - describe "when passed params, separator" do - it "sets self's body based on the passed form parameters and the passed separator" do - @headers.send(@method, {"cmd" => "search", "q" => "ruby", "max" => "50"}, "&") - @headers.body.split("&").sort.should == ["cmd=search", "max=50", "q=ruby"] - - @headers.send(@method, {"cmd" => "search", "q" => "ruby", "max" => "50"}, ";") - @headers.body.split(";").sort.should == ["cmd=search", "max=50", "q=ruby"] - end - 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 deleted file mode 100644 index 87f51d46f3..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/set_range.rb +++ /dev/null @@ -1,89 +0,0 @@ -describe :net_httpheader_set_range, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - describe "when passed nil" do - it "returns nil" do - @headers.send(@method, nil).should be_nil - end - - it "deletes the 'Range' header entry" do - @headers["Range"] = "bytes 0-499/1234" - @headers.send(@method, nil) - @headers["Range"].should be_nil - end - end - - describe "when passed Numeric" do - it "sets the 'Range' header entry based on the passed Numeric" do - @headers.send(@method, 10) - @headers["Range"].should == "bytes=0-9" - - @headers.send(@method, -10) - @headers["Range"].should == "bytes=-10" - - @headers.send(@method, 10.9) - @headers["Range"].should == "bytes=0-9" - end - end - - describe "when passed Range" do - it "sets the 'Range' header entry based on the passed Range" do - @headers.send(@method, 10..200) - @headers["Range"].should == "bytes=10-200" - - @headers.send(@method, 1..5) - @headers["Range"].should == "bytes=1-5" - - @headers.send(@method, 1...5) - @headers["Range"].should == "bytes=1-4" - - @headers.send(@method, 234..567) - @headers["Range"].should == "bytes=234-567" - - @headers.send(@method, -5..-1) - @headers["Range"].should == "bytes=-5" - - @headers.send(@method, 1..-1) - @headers["Range"].should == "bytes=1-" - end - - it "raises a Net::HTTPHeaderSyntaxError when the first Range element is negative" do - -> { @headers.send(@method, -10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when the last Range element is negative" do - -> { @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 - -> { @headers.send(@method, 10..5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - end - - describe "when passed start, end" do - it "sets the 'Range' header entry based on the passed start and length values" do - @headers.send(@method, 10, 200) - @headers["Range"].should == "bytes=10-209" - - @headers.send(@method, 1, 5) - @headers["Range"].should == "bytes=1-5" - - @headers.send(@method, 234, 567) - @headers["Range"].should == "bytes=234-800" - end - - it "raises a Net::HTTPHeaderSyntaxError when start is negative" do - -> { @headers.send(@method, -10, 5) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when start + length is negative" do - -> { @headers.send(@method, 10, -15) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - - it "raises a Net::HTTPHeaderSyntaxError when length is negative" do - -> { @headers.send(@method, 10, -4) }.should raise_error(Net::HTTPHeaderSyntaxError) - end - end -end diff --git a/spec/ruby/library/net/http/httpheader/shared/size.rb b/spec/ruby/library/net/http/httpheader/shared/size.rb deleted file mode 100644 index e2b1e4c22b..0000000000 --- a/spec/ruby/library/net/http/httpheader/shared/size.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe :net_httpheader_size, shared: true do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the number of header entries in self" do - @headers.send(@method).should eql(0) - - @headers["a"] = "b" - @headers.send(@method).should eql(1) - - @headers["b"] = "b" - @headers.send(@method).should eql(2) - - @headers["c"] = "c" - @headers.send(@method).should eql(3) - end -end diff --git a/spec/ruby/library/net/http/httpheader/size_spec.rb b/spec/ruby/library/net/http/httpheader/size_spec.rb deleted file mode 100644 index a7d78f96e0..0000000000 --- a/spec/ruby/library/net/http/httpheader/size_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' -require_relative 'shared/size' - -describe "Net::HTTPHeader#size" do - it_behaves_like :net_httpheader_size, :size -end diff --git a/spec/ruby/library/net/http/httpheader/sub_type_spec.rb b/spec/ruby/library/net/http/httpheader/sub_type_spec.rb deleted file mode 100644 index 3c73ca0027..0000000000 --- a/spec/ruby/library/net/http/httpheader/sub_type_spec.rb +++ /dev/null @@ -1,32 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#sub_type" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns the 'sub-content-type', as per 'Content-Type' header entry" do - @headers["Content-Type"] = "text/html" - @headers.sub_type.should == "html" - - @headers["Content-Type"] = "application/pdf" - @headers.sub_type.should == "pdf" - - @headers["Content-Type"] = "text/html;charset=utf-8" - @headers.sub_type.should == "html" - end - - it "returns nil if no 'sub-content-type' is set" do - @headers["Content-Type"] = "text" - @headers.sub_type.should be_nil - - @headers["Content-Type"] = "text;charset=utf-8" - @headers.sub_type.should be_nil - end - - it "returns nil if the 'Content-Type' header entry does not exist" do - @headers.sub_type.should be_nil - end -end diff --git a/spec/ruby/library/net/http/httpheader/to_hash_spec.rb b/spec/ruby/library/net/http/httpheader/to_hash_spec.rb deleted file mode 100644 index 8c1d36c30a..0000000000 --- a/spec/ruby/library/net/http/httpheader/to_hash_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#to_hash" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns a Hash representing all Header entries (keys in lower case, values as arrays)" do - @headers.to_hash.should == {} - - @headers["My-Header"] = "test" - @headers.to_hash.should == { "my-header" => ["test"] } - - @headers.add_field("My-Header", "another test") - @headers.to_hash.should == { "my-header" => ["test", "another test"] } - end - - it "does not allow modifying the headers from the returned hash" do - @headers.to_hash["my-header"] = ["test"] - @headers.to_hash.should == {} - @headers.key?("my-header").should be_false - end -end diff --git a/spec/ruby/library/net/http/httpheader/type_params_spec.rb b/spec/ruby/library/net/http/httpheader/type_params_spec.rb deleted file mode 100644 index e77be7ea85..0000000000 --- a/spec/ruby/library/net/http/httpheader/type_params_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'fixtures/classes' - -describe "Net::HTTPHeader#type_params" do - before :each do - @headers = NetHTTPHeaderSpecs::Example.new - end - - it "returns additional 'Content-Type' information as a Hash" do - @headers["Content-Type"] = "text/html;charset=utf-8" - @headers.type_params.should == {"charset" => "utf-8"} - - @headers["Content-Type"] = "text/html; charset=utf-8; rubyspec=rocks" - @headers.type_params.should == {"charset" => "utf-8", "rubyspec" => "rocks"} - end - - it "returns an empty Hash when no additional 'Content-Type' information is set" do - @headers.type_params.should == {} - - @headers["Content-Type"] = "text/html" - @headers.type_params.should == {} - end -end diff --git a/spec/ruby/library/net/http/httprequest/initialize_spec.rb b/spec/ruby/library/net/http/httprequest/initialize_spec.rb deleted file mode 100644 index 88e9fb1c77..0000000000 --- a/spec/ruby/library/net/http/httprequest/initialize_spec.rb +++ /dev/null @@ -1,45 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -module NetHTTPRequestSpecs - class TestRequest < Net::HTTPRequest - METHOD = "TEST" - REQUEST_HAS_BODY = false - RESPONSE_HAS_BODY = true - end -end - -describe "Net::HTTPRequest#initialize" do - before :each do - @req = NetHTTPRequestSpecs::TestRequest.allocate - end - - it "uses the METHOD constants to set the request method" do - @req.send(:initialize, "/some/path") - @req.method.should == "TEST" - end - - it "uses the REQUEST_HAS_BODY to set whether the Request has a body or not" do - @req.send(:initialize, "/some/path") - @req.request_body_permitted?.should be_false - end - - it "uses the RESPONSE_HAS_BODY to set whether the Response can have a body or not" do - @req.send(:initialize, "/some/path") - @req.response_body_permitted?.should be_true - end - - describe "when passed path" do - it "sets self's path to the passed path" do - @req.send(:initialize, "/some/path") - @req.path.should == "/some/path" - end - end - - describe "when passed path, headers" do - it "uses the passed headers Hash to initialize self's header entries" do - @req.send(:initialize, "/some/path", "Content-Type" => "text/html") - @req["Content-Type"].should == "text/html" - end - end -end diff --git a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb b/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb deleted file mode 100644 index 8ade46689f..0000000000 --- a/spec/ruby/library/net/http/httpresponse/body_permitted_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse.body_permitted?" do - it "returns true if this response type can have a response body" do - Net::HTTPUnknownResponse.should.body_permitted? - Net::HTTPInformation.should_not.body_permitted? - Net::HTTPSuccess.should.body_permitted? - Net::HTTPRedirection.should.body_permitted? - Net::HTTPClientError.should.body_permitted? - Net::HTTPServerError.should.body_permitted? - end -end diff --git a/spec/ruby/library/net/http/httpresponse/body_spec.rb b/spec/ruby/library/net/http/httpresponse/body_spec.rb deleted file mode 100644 index 79569441f1..0000000000 --- a/spec/ruby/library/net/http/httpresponse/body_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'shared/body' - -describe "Net::HTTPResponse#body" do - it_behaves_like :net_httpresponse_body, :body -end diff --git a/spec/ruby/library/net/http/httpresponse/code_spec.rb b/spec/ruby/library/net/http/httpresponse/code_spec.rb deleted file mode 100644 index 114277cb43..0000000000 --- a/spec/ruby/library/net/http/httpresponse/code_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#code" do - it "returns the result code string" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.code.should == "???" - - res = Net::HTTPInformation.new("1.0", "1xx", "test response") - res.code.should == "1xx" - - res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - res.code.should == "2xx" - - res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - res.code.should == "3xx" - - res = Net::HTTPClientError.new("1.0", "4xx", "test response") - res.code.should == "4xx" - - res = Net::HTTPServerError.new("1.0", "5xx", "test response") - res.code.should == "5xx" - end -end diff --git a/spec/ruby/library/net/http/httpresponse/code_type_spec.rb b/spec/ruby/library/net/http/httpresponse/code_type_spec.rb deleted file mode 100644 index fa2d572e9a..0000000000 --- a/spec/ruby/library/net/http/httpresponse/code_type_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#code_type" do - it "returns self's class" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.code_type.should == Net::HTTPUnknownResponse - - res = Net::HTTPInformation.new("1.0", "1xx", "test response") - res.code_type.should == Net::HTTPInformation - - res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - res.code_type.should == Net::HTTPSuccess - - res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - res.code_type.should == Net::HTTPRedirection - - res = Net::HTTPClientError.new("1.0", "4xx", "test response") - res.code_type.should == Net::HTTPClientError - - res = Net::HTTPServerError.new("1.0", "5xx", "test response") - res.code_type.should == Net::HTTPServerError - end -end diff --git a/spec/ruby/library/net/http/httpresponse/entity_spec.rb b/spec/ruby/library/net/http/httpresponse/entity_spec.rb deleted file mode 100644 index f1639042c1..0000000000 --- a/spec/ruby/library/net/http/httpresponse/entity_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require_relative 'shared/body' - -describe "Net::HTTPResponse#entity" do - it_behaves_like :net_httpresponse_body, :entity -end diff --git a/spec/ruby/library/net/http/httpresponse/error_spec.rb b/spec/ruby/library/net/http/httpresponse/error_spec.rb deleted file mode 100644 index 89f4a47f60..0000000000 --- a/spec/ruby/library/net/http/httpresponse/error_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -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") - -> { res.error! }.should raise_error(Net::HTTPError) - - res = Net::HTTPInformation.new("1.0", "1xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) - - res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPError) - - res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPRetriableError) - - res = Net::HTTPClientError.new("1.0", "4xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPClientException) - - res = Net::HTTPServerError.new("1.0", "5xx", "test response") - -> { res.error! }.should raise_error(Net::HTTPFatalError) - end -end diff --git a/spec/ruby/library/net/http/httpresponse/error_type_spec.rb b/spec/ruby/library/net/http/httpresponse/error_type_spec.rb deleted file mode 100644 index 8885b7706b..0000000000 --- a/spec/ruby/library/net/http/httpresponse/error_type_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#error_type" do - it "returns self's class 'EXCEPTION_TYPE' constant" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.error_type.should == Net::HTTPError - - res = Net::HTTPInformation.new("1.0", "1xx", "test response") - res.error_type.should == Net::HTTPError - - res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - res.error_type.should == Net::HTTPError - - res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - res.error_type.should == Net::HTTPRetriableError - - res = Net::HTTPClientError.new("1.0", "4xx", "test response") - res.error_type.should == Net::HTTPClientException - - res = Net::HTTPServerError.new("1.0", "5xx", "test response") - res.error_type.should == Net::HTTPFatalError - end -end diff --git a/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb b/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb deleted file mode 100644 index 0c9c11291f..0000000000 --- a/spec/ruby/library/net/http/httpresponse/exception_type_spec.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse.exception_type" do - it "returns self's 'EXCEPTION_TYPE' constant" do - Net::HTTPUnknownResponse.exception_type.should == Net::HTTPError - 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::HTTPClientException - Net::HTTPServerError.exception_type.should == Net::HTTPFatalError - end -end diff --git a/spec/ruby/library/net/http/httpresponse/header_spec.rb b/spec/ruby/library/net/http/httpresponse/header_spec.rb deleted file mode 100644 index a9615feda8..0000000000 --- a/spec/ruby/library/net/http/httpresponse/header_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#header" do - it "returns self" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) - end -end diff --git a/spec/ruby/library/net/http/httpresponse/http_version_spec.rb b/spec/ruby/library/net/http/httpresponse/http_version_spec.rb deleted file mode 100644 index db85696d77..0000000000 --- a/spec/ruby/library/net/http/httpresponse/http_version_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#http_version" do - it "returns self's http version" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.http_version.should == "1.0" - - res = Net::HTTPUnknownResponse.new("1.1", "???", "test response") - res.http_version.should == "1.1" - end -end diff --git a/spec/ruby/library/net/http/httpresponse/initialize_spec.rb b/spec/ruby/library/net/http/httpresponse/initialize_spec.rb deleted file mode 100644 index eb77e2e277..0000000000 --- a/spec/ruby/library/net/http/httpresponse/initialize_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#initialize when passed http_version, response_code, response_message" do - it "sets self http_version, response_code and response_message to the passed values" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.http_version.should == "1.0" - res.code.should == "???" - res.message.should == "test response" - end -end diff --git a/spec/ruby/library/net/http/httpresponse/inspect_spec.rb b/spec/ruby/library/net/http/httpresponse/inspect_spec.rb deleted file mode 100644 index 1e1a2c7cc7..0000000000 --- a/spec/ruby/library/net/http/httpresponse/inspect_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require "stringio" - -describe "Net::HTTPResponse#inspect" do - it "returns a String representation of self" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.inspect.should == "#<Net::HTTPUnknownResponse ??? test response readbody=false>" - - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - socket = Net::BufferedIO.new(StringIO.new("test body")) - res.reading_body(socket, true) {} - res.inspect.should == "#<Net::HTTPUnknownResponse ??? test response readbody=true>" - end -end diff --git a/spec/ruby/library/net/http/httpresponse/message_spec.rb b/spec/ruby/library/net/http/httpresponse/message_spec.rb deleted file mode 100644 index ae8e3678a1..0000000000 --- a/spec/ruby/library/net/http/httpresponse/message_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#message" do - it "returns self's response message" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.message.should == "test response" - end -end diff --git a/spec/ruby/library/net/http/httpresponse/msg_spec.rb b/spec/ruby/library/net/http/httpresponse/msg_spec.rb deleted file mode 100644 index 0e5e7eb4aa..0000000000 --- a/spec/ruby/library/net/http/httpresponse/msg_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#msg" do - it "returns self's response message" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.message.should == "test response" - 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 deleted file mode 100644 index ec9b42f919..0000000000 --- a/spec/ruby/library/net/http/httpresponse/read_body_spec.rb +++ /dev/null @@ -1,86 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require 'stringio' - -describe "Net::HTTPResponse#read_body" do - before :each do - @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) - end - - describe "when passed no arguments" do - it "returns the read body" do - @res.reading_body(@socket, true) do - @res.read_body.should == "test body" - end - end - - it "returns the previously read body if called a second time" do - @res.reading_body(@socket, true) do - @res.read_body.should equal(@res.read_body) - end - end - end - - describe "when passed a buffer" do - it "reads the body to the passed buffer" do - @res.reading_body(@socket, true) do - buffer = "" - @res.read_body(buffer) - buffer.should == "test body" - end - end - - it "returns the passed buffer" do - @res.reading_body(@socket, true) do - buffer = "" - @res.read_body(buffer).should equal(buffer) - end - end - - it "raises an IOError if called a second time" do - @res.reading_body(@socket, true) do - @res.read_body("") - -> { @res.read_body("") }.should raise_error(IOError) - end - end - end - - describe "when passed a block" do - it "reads the body and yields it to the passed block (in chunks)" do - @res.reading_body(@socket, true) do - yielded = false - - buffer = "" - @res.read_body do |body| - yielded = true - buffer << body - end - - yielded.should be_true - buffer.should == "test body" - end - end - - it "returns the ReadAdapter" do - @res.reading_body(@socket, true) do - @res.read_body { nil }.should be_kind_of(Net::ReadAdapter) - end - end - - it "raises an IOError if called a second time" do - @res.reading_body(@socket, true) do - @res.read_body {} - -> { @res.read_body {} }.should raise_error(IOError) - end - end - end - - describe "when passed buffer and block" do - it "raises an ArgumentError" do - @res.reading_body(@socket, true) do - -> { @res.read_body("") {} }.should raise_error(ArgumentError) - end - end - end -end diff --git a/spec/ruby/library/net/http/httpresponse/read_header_spec.rb b/spec/ruby/library/net/http/httpresponse/read_header_spec.rb deleted file mode 100644 index 6af8c6bd6a..0000000000 --- a/spec/ruby/library/net/http/httpresponse/read_header_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#read_header" do - it "returns self" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) - end -end diff --git a/spec/ruby/library/net/http/httpresponse/read_new_spec.rb b/spec/ruby/library/net/http/httpresponse/read_new_spec.rb deleted file mode 100644 index dc2cdc9621..0000000000 --- a/spec/ruby/library/net/http/httpresponse/read_new_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require 'stringio' - -describe "Net::HTTPResponse.read_new" do - it "creates a HTTPResponse object based on the response read from the passed socket" do - socket = Net::BufferedIO.new(StringIO.new(<<EOS)) -HTTP/1.1 200 OK -Content-Type: text/html; charset=utf-8 - -test-body -EOS - response = Net::HTTPResponse.read_new(socket) - - response.should be_kind_of(Net::HTTPOK) - response.code.should == "200" - response["Content-Type"].should == "text/html; charset=utf-8" - - response.reading_body(socket, true) do - response.body.should == "test-body\n" - end - end -end diff --git a/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb b/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb deleted file mode 100644 index ebdab891e1..0000000000 --- a/spec/ruby/library/net/http/httpresponse/reading_body_spec.rb +++ /dev/null @@ -1,58 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' -require "stringio" - -describe "Net::HTTPResponse#reading_body" do - before :each do - @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) - end - - describe "when body_allowed is true" do - it "reads and returns the response body for self from the passed socket" do - @res.reading_body(@socket, true) {}.should == "test body" - @res.body.should == "test body" - end - - it "yields the passed block before reading the body" do - yielded = false - - @res.reading_body(@socket, true) do - @res.inspect.should == "#<Net::HTTPUnknownResponse ??? test response readbody=false>" - yielded = true - end - - yielded.should be_true - end - - describe "but the response type is not allowed to have a body" do - before :each do - @res = Net::HTTPInformation.new("1.0", "???", "test response") - end - - it "returns nil" do - @res.reading_body(@socket, false) {}.should be_nil - @res.body.should be_nil - end - - it "yields the passed block" do - yielded = false - @res.reading_body(@socket, true) { yielded = true } - yielded.should be_true - end - end - end - - describe "when body_allowed is false" do - it "returns nil" do - @res.reading_body(@socket, false) {}.should be_nil - @res.body.should be_nil - end - - it "yields the passed block" do - yielded = false - @res.reading_body(@socket, true) { yielded = true } - yielded.should be_true - end - end -end diff --git a/spec/ruby/library/net/http/httpresponse/response_spec.rb b/spec/ruby/library/net/http/httpresponse/response_spec.rb deleted file mode 100644 index f6035f3695..0000000000 --- a/spec/ruby/library/net/http/httpresponse/response_spec.rb +++ /dev/null @@ -1,9 +0,0 @@ -require_relative '../../../../spec_helper' -require 'net/http' - -describe "Net::HTTPResponse#response" do - it "returns self" do - res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - res.response.should equal(res) - end -end diff --git a/spec/ruby/library/net/http/httpresponse/shared/body.rb b/spec/ruby/library/net/http/httpresponse/shared/body.rb deleted file mode 100644 index 618e3936fb..0000000000 --- a/spec/ruby/library/net/http/httpresponse/shared/body.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'stringio' - -describe :net_httpresponse_body, shared: true do - before :each do - @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) - end - - it "returns the read body" do - @res.reading_body(@socket, true) do - @res.send(@method).should == "test body" - end - end - - it "returns the previously read body if called a second time" do - @res.reading_body(@socket, true) do - @res.send(@method).should equal(@res.send(@method)) - 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 deleted file mode 100644 index 5cd58316ef..0000000000 --- a/spec/ruby/library/net/http/httpresponse/value_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative '../../../../spec_helper' -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") - -> { res.value }.should raise_error(Net::HTTPError) - - res = Net::HTTPInformation.new("1.0", "1xx", "test response") - -> { res.value }.should raise_error(Net::HTTPError) - - res = Net::HTTPSuccess.new("1.0", "2xx", "test response") - -> { res.value }.should_not raise_error(Net::HTTPError) - - res = Net::HTTPRedirection.new("1.0", "3xx", "test response") - -> { res.value }.should raise_error(Net::HTTPRetriableError) - - res = Net::HTTPClientError.new("1.0", "4xx", "test response") - -> { res.value }.should raise_error(Net::HTTPClientException) - - res = Net::HTTPServerError.new("1.0", "5xx", "test response") - -> { res.value }.should raise_error(Net::HTTPFatalError) - end -end |