diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-06 15:15:41 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-02-08 13:49:12 -0800 |
commit | e8d3d5792548b78264474a016cbeaeed8621bea7 (patch) | |
tree | 92647ae17469c93e66ab3f3ec57420206587638d | |
parent | 874c8b4f384a381fa655cb895a266801551b4f4f (diff) | |
download | chef-e8d3d5792548b78264474a016cbeaeed8621bea7.tar.gz |
fix return of which()
also clean up a confusing spec test
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/mixin/which.rb | 2 | ||||
-rw-r--r-- | spec/unit/util/selinux_spec.rb | 15 |
2 files changed, 3 insertions, 14 deletions
diff --git a/lib/chef/mixin/which.rb b/lib/chef/mixin/which.rb index 92934ce485..a81aacd89b 100644 --- a/lib/chef/mixin/which.rb +++ b/lib/chef/mixin/which.rb @@ -19,7 +19,7 @@ class Chef module Mixin module Which def which(*cmds, extra_path: nil, &block) - where(*cmds, extra_path: extra_path, &block).first + where(*cmds, extra_path: extra_path, &block).first || false end def where(*cmds, extra_path: nil, &block) diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index 609ff02215..69d1ccdb1f 100644 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -148,21 +148,10 @@ describe Chef::Util::Selinux do end describe "when restorecon doesn't exist on the system" do - before do - allow(File).to receive(:executable?) do |file_path| - expect(file_path.end_with?("restorecon")).to be_truthy - false - end - end - it "should log a warning message" do - log = [ ] - allow(Chef::Log).to receive(:warn) do |message| - log << message - end - + allow(File).to receive(:executable?).with(/restorecon$/).and_return(false) + expect(Chef::Log).to receive(:warn).with(/Can not find 'restorecon' on the system. Skipping selinux security context restore./).at_least(:once) @test_instance.restore_security_context(path) - expect(log).not_to be_empty expect(File).not_to receive(:executable?) @test_instance.restore_security_context(path) end |