Add fallback for hostname
if uname
isn't available. (#12655)
This commit is contained in:
parent
baf22a0578
commit
d3abee739f
Notes:
git
2025-01-28 12:20:26 +00:00
Merged-By: ioquatix <samuel@codeotaku.com>
@ -2,7 +2,15 @@ require_relative '../spec_helper'
|
|||||||
require_relative '../fixtures/classes'
|
require_relative '../fixtures/classes'
|
||||||
|
|
||||||
describe "Socket.gethostname" do
|
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
|
||||||
|
end
|
||||||
|
|
||||||
it "returns the host name" do
|
it "returns the host name" do
|
||||||
Socket.gethostname.should == `uname -n`.strip
|
Socket.gethostname.should == system_hostname
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user