Method: Object#hostname

Defined in:
lib/mspec/helpers/environment.rb

#hostnameObject

Raises:

  • (Exception)


41
42
43
44
45
46
47
48
# File 'lib/mspec/helpers/environment.rb', line 41

def hostname
  commands = ['hostname', 'uname -n']
  commands.each do |command|
    name = `#{command}`
    return name.strip if $?.success?
  end
  raise Exception, "hostname: unable to find a working command"
end