diff --git a/spec/std/system/user_spec.cr b/spec/std/system/user_spec.cr index f0cb977d014d..32f2126d13c0 100644 --- a/spec/std/system/user_spec.cr +++ b/spec/std/system/user_spec.cr @@ -2,9 +2,9 @@ require "spec" require "system/user" {% if flag?(:win32) %} - {% name, id = `whoami /USER /FO TABLE /NH`.stringify.chomp.split(" ") %} - USER_NAME = {{ name }} - USER_ID = {{ id }} + {% parts = `whoami /USER /FO TABLE /NH`.stringify.chomp.split(" ") %} + USER_NAME = {{ parts[0..-2].join(" ") }} + USER_ID = {{ parts[-1] }} {% else %} USER_NAME = {{ `id -un`.stringify.chomp }} USER_ID = {{ `id -u`.stringify.chomp }} @@ -17,8 +17,7 @@ def normalized_username(username) # on Windows, domain names are case-insensitive, so we unify the letter case # from sources like `whoami`, `hostname`, or Win32 APIs {% if flag?(:win32) %} - domain, _, user = username.partition('\\') - "#{domain.upcase}\\#{user}" + username.upcase {% else %} username {% end %}