summaryrefslogtreecommitdiff
path: root/test/resolv/test_dns.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-19 14:24:01 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-19 14:24:01 +0900
commitadcbae8d49ec04d365ce13274783b1495c3c7d0e (patch)
tree02c403c410ebe6170e950001c58b90943064f28a /test/resolv/test_dns.rb
parent1d170fdc6d0af128c9e5ea2d6082790d5885a4ae (diff)
Removed minitest/mock
Diffstat (limited to 'test/resolv/test_dns.rb')
-rw-r--r--test/resolv/test_dns.rb31
1 files changed, 30 insertions, 1 deletions
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
index 1f1555fecc..5171604a82 100644
--- a/test/resolv/test_dns.rb
+++ b/test/resolv/test_dns.rb
@@ -3,7 +3,36 @@ require 'test/unit'
require 'resolv'
require 'socket'
require 'tempfile'
-require 'minitest/mock'
+
+class Object # :nodoc:
+ def stub name, val_or_callable, &block
+ new_name = "__minitest_stub__#{name}"
+
+ metaclass = class << self; self; end
+
+ if respond_to? name and not methods.map(&:to_s).include? name.to_s then
+ metaclass.send :define_method, name do |*args|
+ super(*args)
+ end
+ end
+
+ metaclass.send :alias_method, new_name, name
+
+ metaclass.send :define_method, name do |*args|
+ if val_or_callable.respond_to? :call then
+ val_or_callable.call(*args)
+ else
+ val_or_callable
+ end
+ end
+
+ yield self
+ ensure
+ metaclass.send :undef_method, name
+ metaclass.send :alias_method, name, new_name
+ metaclass.send :undef_method, new_name
+ end unless method_defined?(:stub) # lib/rubygems/test_case.rb also has the same method definition
+end
class TestResolvDNS < Test::Unit::TestCase
def setup