diff options
author | Antonio Terceiro <asa@terceiro.xyz> | 2020-03-08 11:17:18 -0300 |
---|---|---|
committer | Antonio Terceiro <asa@terceiro.xyz> | 2020-03-08 19:15:32 -0300 |
commit | 1d47f8f55c9c1b65712adf7d6d48d91aed8b4514 (patch) | |
tree | 9d39f68cce119bce352aeeaa38d43e21f39e0a35 | |
parent | 528ebf0f545d9bc0ef1d3f129134818855b1cf45 (diff) | |
download | mixlib-shellout-1d47f8f55c9c1b65712adf7d6d48d91aed8b4514.tar.gz |
shellout_spec: make "current user" independent of the environment
There is no guarantee that ENV["USER"] is always present, and in some
environments, it's not. Get the current user from Etc.getpwuid, which
works even in the absence of any environment variables.
Signed-off-by: Antonio Terceiro <asa@terceiro.xyz>
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index ed5e30a..da3e543 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -1,4 +1,5 @@ require "spec_helper" +require "etc" require "logger" require "timeout" @@ -1532,7 +1533,7 @@ describe Mixlib::ShellOut do context "when no user is set" do it "should run as current user" do - expect(running_user).to eql(ENV["USER"]) + expect(running_user).to eql(Etc.getpwuid.name) end end |