diff options
author | Samuel Williams <[email protected]> | 2025-02-01 00:28:35 +1300 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2025-01-31 13:00:26 +0100 |
commit | 0da2b12741b2645f5c34f7e98e3b3b0f8f3cde5e (patch) | |
tree | 5004b49faabeaf0720677c2569d266b1a349834f | |
parent | f719b889a149b1caad3550a70547e9e64f371f2f (diff) |
Prefer `platform_is_not :windows`.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12682
-rw-r--r-- | spec/ruby/library/socket/socket/gethostname_spec.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/spec/ruby/library/socket/socket/gethostname_spec.rb b/spec/ruby/library/socket/socket/gethostname_spec.rb index 89e1ed496f..dfca7cf5cd 100644 --- a/spec/ruby/library/socket/socket/gethostname_spec.rb +++ b/spec/ruby/library/socket/socket/gethostname_spec.rb @@ -3,11 +3,13 @@ require_relative '../fixtures/classes' describe "Socket.gethostname" do def system_hostname - # Most platforms implement this POSIX standard: - `uname -n`.strip - rescue - # Only really required for Windows without MSYS/MinGW/Cygwin etc: - `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: + `hostname`.strip + end end it "returns the host name" do |