From 32050808ee48d927d4c642cc35eeeb8611851dec Mon Sep 17 00:00:00 2001 From: "William T. Nelson" <35801+wtn@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:04:19 -0600 Subject: [PATCH] Use Struct instead of OpenStruct in tests ostruct is a bundled gem in Ruby 4.0 and is not in the Gemfile, so `bundle exec rake test` fails with a LoadError. Co-authored-by: Claude Opus 5.5 --- test/net/ftp/test_buffered_socket.rb | 1 - test/net/ftp/test_ftp.rb | 12 +++++------- test/net/ftp/test_mlsx_entry.rb | 1 - 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/test/net/ftp/test_buffered_socket.rb b/test/net/ftp/test_buffered_socket.rb index 875c53f..fdc68bb 100644 --- a/test/net/ftp/test_buffered_socket.rb +++ b/test/net/ftp/test_buffered_socket.rb @@ -2,7 +2,6 @@ require "net/ftp" require "test/unit" -require "ostruct" require "stringio" class BufferedSocketTest < Test::Unit::TestCase diff --git a/test/net/ftp/test_ftp.rb b/test/net/ftp/test_ftp.rb index 34e11d0..4f2495e 100644 --- a/test/net/ftp/test_ftp.rb +++ b/test/net/ftp/test_ftp.rb @@ -2,7 +2,6 @@ require "net/ftp" require "test/unit" -require "ostruct" require "stringio" require "tempfile" require "tmpdir" @@ -70,6 +69,9 @@ def test_connect_fail end end + FakeSocket = Struct.new(:remote_address) + FakeAddress = Struct.new(:ip_address) + def test_parse227 ftp = Net::FTP.new(nil, use_pasv_ip: true) host, port = ftp.send(:parse227, "227 Entering Passive Mode (192,168,0,1,12,34)") @@ -92,9 +94,7 @@ def test_parse227 end ftp = Net::FTP.new - sock = OpenStruct.new - sock.remote_address = OpenStruct.new - sock.remote_address.ip_address = "10.0.0.1" + sock = FakeSocket.new(FakeAddress.new("10.0.0.1")) ftp.instance_variable_set(:@bare_sock, sock) host, port = ftp.send(:parse227, "227 Entering Passive Mode (192,168,0,1,12,34)") assert_equal("10.0.0.1", host) @@ -102,9 +102,7 @@ def test_parse227 def test_parse229 ftp = Net::FTP.new - sock = OpenStruct.new - sock.remote_address = OpenStruct.new - sock.remote_address.ip_address = "1080:0000:0000:0000:0008:0800:200c:417a" + sock = FakeSocket.new(FakeAddress.new("1080:0000:0000:0000:0008:0800:200c:417a")) ftp.instance_variable_set(:@bare_sock, sock) host, port = ftp.send(:parse229, "229 Entering Passive Mode (|||3106|)") assert_equal("1080:0000:0000:0000:0008:0800:200c:417a", host) diff --git a/test/net/ftp/test_mlsx_entry.rb b/test/net/ftp/test_mlsx_entry.rb index 92fe411..93eee06 100644 --- a/test/net/ftp/test_mlsx_entry.rb +++ b/test/net/ftp/test_mlsx_entry.rb @@ -2,7 +2,6 @@ require "net/ftp" require "test/unit" -require "ostruct" require "stringio" class MLSxEntryTest < Test::Unit::TestCase