Skip to content

Commit

Permalink
spec: Use 127.0.0.1 instead of localhost (fixes #172)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri committed Nov 14, 2017
1 parent e653220 commit c9202d8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions spec/nio/acceptables_spec.rb
Expand Up @@ -20,13 +20,13 @@
let(:port) { next_available_tcp_port }

let :acceptable_subject do
server = TCPServer.new("localhost", port)
TCPSocket.open("localhost", port)
server = TCPServer.new("127.0.0.1", port)
TCPSocket.open("127.0.0.1", port)
server
end

let :unacceptable_subject do
TCPServer.new("localhost", port + 1)
TCPServer.new("127.0.0.1", port + 1)
end

it_behaves_like "an NIO acceptable"
Expand Down
2 changes: 1 addition & 1 deletion spec/nio/bytebuffer_spec.rb
Expand Up @@ -281,7 +281,7 @@
end

context "I/O" do
let(:addr) { "localhost" }
let(:addr) { "127.0.0.1" }
let(:port) { next_available_tcp_port }
let(:server) { TCPServer.new(addr, port) }
let(:client) { TCPSocket.new(addr, port) }
Expand Down
2 changes: 1 addition & 1 deletion spec/nio/monitor_spec.rb
Expand Up @@ -4,7 +4,7 @@
require "socket"

RSpec.describe NIO::Monitor do
let(:addr) { "localhost" }
let(:addr) { "127.0.0.1" }
let(:port) { next_available_tcp_port }

let(:reader) { TCPServer.new(addr, port) }
Expand Down
4 changes: 2 additions & 2 deletions spec/nio/selectables/ssl_socket_spec.rb
Expand Up @@ -4,13 +4,13 @@
require "openssl"

RSpec.describe OpenSSL::SSL::SSLSocket do
let(:addr) { "localhost" }
let(:addr) { "127.0.0.1" }
let(:port) { next_available_tcp_port }

let(:ssl_key) { OpenSSL::PKey::RSA.new(1024) }

let(:ssl_cert) do
name = OpenSSL::X509::Name.new([%w(CN localhost)])
name = OpenSSL::X509::Name.new([%w(CN 127.0.0.1)])
OpenSSL::X509::Certificate.new.tap do |cert|
cert.version = 2
cert.serial = 1
Expand Down
8 changes: 4 additions & 4 deletions spec/nio/selectables/udp_socket_spec.rb
Expand Up @@ -7,23 +7,23 @@

let :readable_subject do
sock = UDPSocket.new
sock.bind("localhost", udp_port)
sock.bind("127.0.0.1", udp_port)

peer = UDPSocket.new
peer.send("hi there", 0, "localhost", udp_port)
peer.send("hi there", 0, "127.0.0.1", udp_port)

sock
end

let :unreadable_subject do
sock = UDPSocket.new
sock.bind("localhost", udp_port + 1)
sock.bind("127.0.0.1", udp_port + 1)
sock
end

let :writable_subject do
peer = UDPSocket.new
peer.connect "localhost", udp_port
peer.connect "127.0.0.1", udp_port
cntr = 0
begin
peer.send("X" * 1024, 0)
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Expand Up @@ -20,7 +20,7 @@ def next_available_tcp_port
$current_tcp_port += 1

begin
sock = Timeout.timeout(0.5) { TCPSocket.new("localhost", $current_tcp_port) }
sock = Timeout.timeout(0.5) { TCPSocket.new("127.0.0.1", $current_tcp_port) }
rescue Errno::ECONNREFUSED, Timeout::Error
break $current_tcp_port
end
Expand Down

0 comments on commit c9202d8

Please sign in to comment.