Prefer platform_is_not :windows
.
This commit is contained in:
parent
f719b889a1
commit
0da2b12741
Notes:
git
2025-01-31 12:00:44 +00:00
@ -3,11 +3,13 @@ require_relative '../fixtures/classes'
|
|||||||
|
|
||||||
describe "Socket.gethostname" do
|
describe "Socket.gethostname" do
|
||||||
def system_hostname
|
def system_hostname
|
||||||
# Most platforms implement this POSIX standard:
|
if platform_is_not :windows
|
||||||
`uname -n`.strip
|
# `uname -n` is the most portable way to get the hostname, as it is a POSIX standard:
|
||||||
rescue
|
`uname -n`.strip
|
||||||
# Only really required for Windows without MSYS/MinGW/Cygwin etc:
|
else
|
||||||
`hostname`.strip
|
# Windows does not have uname, so we use hostname instead:
|
||||||
|
`hostname`.strip
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the host name" do
|
it "returns the host name" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user