A platform for community discussion. Free, open, simple.
DEV: Introduce `stub_ip_lookup` spec helper (#20571)
Alan Guo Xiang Tanb5cd22edb679
diff --git a/spec/lib/final_destination/http_spec.rb b/spec/lib/final_destination/http_spec.rbindex 9ef4977826b..fe1132acc82 100644--- a/spec/lib/final_destination/http_spec.rb+++ b/spec/lib/final_destination/http_spec.rb@@ -25,15 +25,6 @@ describe FinalDestination::HTTP doendend- def stub_ip_lookup(stub_addr, ips)- Addrinfo- .stubs(:getaddrinfo)- .with { |addr, _| addr == stub_addr }- .returns(- ips.map { |ip| Addrinfo.new([IPAddr.new(ip).ipv6? ? "AF_INET6" : "AF_INET", 80, nil, ip]) },- )- end-def stub_tcp_to_raise(stub_addr, exception)TCPSocket.stubs(:open).with { |addr| addr == stub_addr }.once.raises(exception)enddiff --git a/spec/support/helpers.rb b/spec/support/helpers.rbindex fef1ad63562..ff611df35e3 100644--- a/spec/support/helpers.rb+++ b/spec/support/helpers.rb@@ -192,4 +192,13 @@ module Helpersqueriesend++ def stub_ip_lookup(stub_addr, ips)+ Addrinfo+ .stubs(:getaddrinfo)+ .with { |addr, _| addr == stub_addr }+ .returns(+ ips.map { |ip| Addrinfo.new([IPAddr.new(ip).ipv6? ? "AF_INET6" : "AF_INET", 80, nil, ip]) },+ )+ endend