We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
platform_is_not :windows
1 parent f719b88 commit 0da2b12Copy full SHA for 0da2b12
spec/ruby/library/socket/socket/gethostname_spec.rb
@@ -3,11 +3,13 @@
3
4
describe "Socket.gethostname" do
5
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
+ if platform_is_not :windows
+ # `uname -n` is the most portable way to get the hostname, as it is a POSIX standard:
+ `uname -n`.strip
+ else
+ # Windows does not have uname, so we use hostname instead:
11
+ `hostname`.strip
12
+ end
13
end
14
15
it "returns the host name" do
0 commit comments