aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/net/ftp.rb8
-rw-r--r--spec/ruby/library/net/ftp/initialize_spec.rb12
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index 31c4fb007e..cafe39fad0 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -262,13 +262,7 @@ module Net
@ssl_handshake_timeout = options[:ssl_handshake_timeout]
@read_timeout = options[:read_timeout] || 60
if host
- if options[:port]
- connect(host, options[:port] || FTP_PORT)
- else
- # spec/ruby/library/net/ftp/initialize_spec.rb depends on
- # the number of arguments passed to connect....
- connect(host)
- end
+ connect(host, options[:port] || FTP_PORT)
if options[:username]
login(options[:username], options[:password], options[:account])
end
diff --git a/spec/ruby/library/net/ftp/initialize_spec.rb b/spec/ruby/library/net/ftp/initialize_spec.rb
index 767bbecedb..65105b8831 100644
--- a/spec/ruby/library/net/ftp/initialize_spec.rb
+++ b/spec/ruby/library/net/ftp/initialize_spec.rb
@@ -5,6 +5,10 @@ describe "Net::FTP#initialize" do
before :each do
@ftp = Net::FTP.allocate
@ftp.stub!(:connect)
+ @port_args = []
+ ruby_version_is "2.5" do
+ @port_args << 21
+ end
end
it "is private" do
@@ -44,14 +48,14 @@ describe "Net::FTP#initialize" do
describe "when passed host" do
it "tries to connect to the passed host" do
- @ftp.should_receive(:connect).with("localhost")
+ @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")
+ @ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end
@@ -63,7 +67,7 @@ describe "Net::FTP#initialize" do
describe "when passed host, user, password" do
it "tries to connect to the passed host" do
- @ftp.should_receive(:connect).with("localhost")
+ @ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end
@@ -75,7 +79,7 @@ describe "Net::FTP#initialize" do
describe "when passed host, user" do
it "tries to connect to the passed host" do
- @ftp.should_receive(:connect).with("localhost")
+ @ftp.should_receive(:connect).with("localhost", *@port_args)
@ftp.send(:initialize, "localhost")
end