summaryrefslogtreecommitdiff
path: root/spec/unit/util
diff options
context:
space:
mode:
authorBryan McLellan <btm@getchef.com>2014-05-12 14:42:22 -0700
committerBryan McLellan <btm@getchef.com>2014-05-15 08:00:55 -0700
commit373d1893837eaae56c2c37e942004097f06a861b (patch)
treebfa5fb105d20c8f0a9325bbbf3a194b3e2437e9f /spec/unit/util
parentdbc7089023c118f12bb0544bc492ccd67f8bf997 (diff)
downloadohai-373d1893837eaae56c2c37e942004097f06a861b.tar.gz
OHAI-573: Only claim to be an LXC Host if we're pretty sure that we are
Diffstat (limited to 'spec/unit/util')
-rw-r--r--spec/unit/util/file_helper_spec.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/unit/util/file_helper_spec.rb b/spec/unit/util/file_helper_spec.rb
new file mode 100644
index 00000000..5c6cf7f6
--- /dev/null
+++ b/spec/unit/util/file_helper_spec.rb
@@ -0,0 +1,45 @@
+# Author:: Bryan McLellan <btm@loftninjas.org>
+#
+# Copyright:: Copyright (c) 2014 Chef Software, Inc.
+#
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require 'spec_helper'
+require 'ohai/util/file_helper'
+
+class FileHelperMock
+ include Ohai::Util::FileHelper
+end
+
+
+describe "Ohai::Util::FileHelper" do
+ let(:file_helper) { FileHelperMock.new }
+
+ before(:each) do
+ File.stub(:executable?).and_return(false)
+ end
+
+ describe "which" do
+ it "returns the path to an executable that is in the path" do
+ File.stub(:executable?).with('/usr/bin/skyhawk').and_return(true)
+
+ expect(file_helper.which('skyhawk')).to eql "/usr/bin/skyhawk"
+ end
+
+ it "returns false if the executable is not in the path" do
+ expect(file_helper.which('the_cake')).to be_false
+ end
+ end
+end