Skip to content

Stop defining a global Object#stub in the DNS tests - #170

Merged
hsbt merged 1 commit into
ruby:masterfrom
ko1:no-global-object-stub
Nov 24, 2026
Merged

hsbt merged 1 commit into
ruby:masterfrom
ko1:no-global-object-stub

Conversation

@ko1

@ko1 ko1 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

The tests defined Object#stub unless one already existed, and the copy dropped the block and keyword arguments. In ruby/ruby's test-all, when test/resolv/test_dns.rb was loaded before the RubyGems tests in the same process, Gem::TestCase picked up this copy instead of its own, and stubs whose callable takes a block failed with "undefined method 'call' for nil":

TestGemCoreExtTCPSocketInit#test_initialize_forwards_socket_arguments
TestGemInstaller#test_install_holds_lock_while_replacing_gem_files

Only assert_no_fd_leak used it, so replace Resolv::DNS.bind_random_port there directly and restore it afterwards.

The tests defined Object#stub unless one already existed, and the copy
dropped the block and keyword arguments.  In ruby/ruby's test-all, when
test/resolv/test_dns.rb was loaded before the RubyGems tests in the same
process, Gem::TestCase picked up this copy instead of its own, and stubs
whose callable takes a block failed with "undefined method 'call' for nil":

  TestGemCoreExtTCPSocketInit#test_initialize_forwards_socket_arguments
  TestGemInstaller#test_install_holds_lock_while_replacing_gem_files

Only assert_no_fd_leak used it, so replace Resolv::DNS.bind_random_port
there directly and restore it afterwards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hsbt
hsbt merged commit a0ff579 into ruby:master Nov 24, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants