Skip to content

Commit 0da2b12

Browse files
ioquatixeregon
authored andcommitted
Prefer platform_is_not :windows.
1 parent f719b88 commit 0da2b12

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

spec/ruby/library/socket/socket/gethostname_spec.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
describe "Socket.gethostname" do
55
def system_hostname
6-
# Most platforms implement this POSIX standard:
7-
`uname -n`.strip
8-
rescue
9-
# Only really required for Windows without MSYS/MinGW/Cygwin etc:
10-
`hostname`.strip
6+
if platform_is_not :windows
7+
# `uname -n` is the most portable way to get the hostname, as it is a POSIX standard:
8+
`uname -n`.strip
9+
else
10+
# Windows does not have uname, so we use hostname instead:
11+
`hostname`.strip
12+
end
1113
end
1214

1315
it "returns the host name" do

0 commit comments

Comments
 (0)