diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2020-07-22 17:24:48 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2020-07-22 17:24:48 -0700 |
commit | df3f9fa4f950827b028efb58b1403f8e4c6f3d08 (patch) | |
tree | 932e2f01d86c39f328ca9c5475e253efb4b0e06a /spec | |
parent | d7deaae8fcf84c19c825e43c487819cde24ed549 (diff) | |
download | chef-df3f9fa4f950827b028efb58b1403f8e4c6f3d08.tar.gz |
Convert to default_paths APIlcg/default-paths
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/mixin/default_paths_spec.rb (renamed from spec/unit/mixin/path_sanity_spec.rb) | 28 | ||||
-rw-r--r-- | spec/unit/mixin/shell_out_spec.rb | 14 |
2 files changed, 21 insertions, 21 deletions
diff --git a/spec/unit/mixin/path_sanity_spec.rb b/spec/unit/mixin/default_paths_spec.rb index 013225f853..0224b8f4ce 100644 --- a/spec/unit/mixin/path_sanity_spec.rb +++ b/spec/unit/mixin/default_paths_spec.rb @@ -18,19 +18,19 @@ require "spec_helper" -class PathSanityTestHarness - include Chef::Mixin::PathSanity +class DefaultPathsTestHarness + include Chef::Mixin::DefaultPaths end -describe Chef::Mixin::PathSanity do +describe Chef::Mixin::DefaultPaths do before do - @sanity = PathSanityTestHarness.new + @default_paths = DefaultPathsTestHarness.new end - describe "when enforcing path sanity" do + describe "when enforcing default paths" do before do - Chef::Config[:enforce_path_sanity] = true + Chef::Config[:enforce_default_paths] = true @ruby_bindir = "/some/ruby/bin" @gem_bindir = "/some/gem/bin" allow(Gem).to receive(:bindir).and_return(@gem_bindir) @@ -40,41 +40,41 @@ describe Chef::Mixin::PathSanity do it "adds all useful PATHs even if environment is an empty hash" do env = {} - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end it "adds all useful PATHs that are not yet in PATH to PATH" do env = { "PATH" => "" } - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end it "does not re-add paths that already exist in PATH" do env = { "PATH" => "/usr/bin:/sbin:/bin" } - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/bin:/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin") end it "creates path with utf-8 encoding" do env = { "PATH" => "/usr/bin:/sbin:/bin:/b#{0x81.chr}t".force_encoding("ISO-8859-1") } - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"].encoding.to_s).to eq("UTF-8") end it "adds the current executing Ruby's bindir and Gem bindir to the PATH" do env = { "PATH" => "" } - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("#{@gem_bindir}:#{@ruby_bindir}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") end - it "does not create entries for Ruby/Gem bindirs if they exist in SANE_PATH or PATH" do + it "does not create entries for Ruby/Gem bindirs if they exist in PATH" do ruby_bindir = "/usr/bin" gem_bindir = "/yo/gabba/gabba" allow(Gem).to receive(:bindir).and_return(gem_bindir) allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) env = { "PATH" => gem_bindir } - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("/usr/bin:/yo/gabba/gabba:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin") end @@ -85,7 +85,7 @@ describe Chef::Mixin::PathSanity do allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) allow(ChefUtils).to receive(:windows?).and_return(true) env = { "PATH" => 'C:\Windows\system32;C:\mr\softie' } - @sanity.enforce_path_sanity(env) + @default_paths.enforce_default_paths(env) expect(env["PATH"]).to eq("#{gem_bindir};#{ruby_bindir};C:\\Windows\\system32;C:\\mr\\softie") end end diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index 5880aa2b6a..2b76a10e6c 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -21,7 +21,7 @@ # require "spec_helper" -require "chef/mixin/path_sanity" +require "chef/mixin/default_paths" describe Chef::Mixin::ShellOut do let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } } @@ -74,7 +74,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.sanitized_path, + env_path => shell_out_obj.default_paths, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) end @@ -87,7 +87,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.sanitized_path, + env_path => shell_out_obj.default_paths, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) expect(options[:environment].key?("LC_ALL")).to be false @@ -115,7 +115,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.sanitized_path, + env_path => shell_out_obj.default_paths, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) end @@ -128,7 +128,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.sanitized_path, + env_path => shell_out_obj.default_paths, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) expect(options[:env].key?("LC_ALL")).to be false @@ -144,7 +144,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.sanitized_path, + env_path => shell_out_obj.default_paths, }).and_return(retobj) shell_out_obj.send(method, cmd, **options) end @@ -158,7 +158,7 @@ describe Chef::Mixin::ShellOut do "LC_ALL" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], - env_path => shell_out_obj.sanitized_path, + env_path => shell_out_obj.default_paths, }).and_return(retobj) shell_out_obj.send(method, cmd) end |