From 1d47f8f55c9c1b65712adf7d6d48d91aed8b4514 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Sun, 8 Mar 2020 11:17:18 -0300 Subject: 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 --- spec/mixlib/shellout_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec') 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 -- cgit v1.2.1