lib/mspec/helpers/environment.rb in mspec-1.5.17 vs lib/mspec/helpers/environment.rb in mspec-1.5.18

- old
+ new

@@ -11,11 +11,11 @@ env end def windows_env_echo(var) `cmd.exe /C ECHO %#{var}%`.strip - end + end def username user = "" if PlatformGuard.windows? user = windows_env_echo('USERNAME') @@ -26,7 +26,24 @@ end def home_directory return ENV['HOME'] unless PlatformGuard.windows? windows_env_echo('HOMEDRIVE') + windows_env_echo('HOMEPATH') - end + end + + def dev_null + if PlatformGuard.windows? + "NUL" + else + "/dev/null" + end + end + + 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 end