diff options
-rw-r--r-- | spec/ruby/library/socket/socket/gethostname_spec.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/ruby/library/socket/socket/gethostname_spec.rb b/spec/ruby/library/socket/socket/gethostname_spec.rb index bdc47dc611..89e1ed496f 100644 --- a/spec/ruby/library/socket/socket/gethostname_spec.rb +++ b/spec/ruby/library/socket/socket/gethostname_spec.rb @@ -2,7 +2,15 @@ require_relative '../spec_helper' 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 + end + it "returns the host name" do - Socket.gethostname.should == `uname -n`.strip + Socket.gethostname.should == system_hostname end end |