diff options
Diffstat (limited to 'spec/support/webmock.rb')
-rw-r--r-- | spec/support/webmock.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb index 171c7ace2d2..1df92ce70cf 100644 --- a/spec/support/webmock.rb +++ b/spec/support/webmock.rb @@ -26,7 +26,14 @@ end def allowed_host_and_ip(url) host = URI.parse(url).host ip_address = Addrinfo.ip(host).ip_address - [host, ip_address] + + allowed = [host, ip_address] + + # Sometimes IPv6 address has square brackets around it + parsed_ip = IPAddr.new(ip_address) + allowed << "[#{ip_address}]" if parsed_ip.ipv6? + + allowed end def with_net_connect_allowed |