summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-03-30 11:46:27 -0700
committerTim Smith <tsmith84@gmail.com>2020-04-02 12:27:12 -0700
commit9f9510513b2e1038d347172119f96a0a868eb105 (patch)
treecbbea4b106e78a9dc16089349270180bf0f17d61 /spec
parent308a3def6fbf8f4039fd5db121d20bcdb965f5cc (diff)
downloadchef-9f9510513b2e1038d347172119f96a0a868eb105.tar.gz
Switch the array format of shell_out and add a test
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/resource/build_essential_spec.rb26
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/unit/resource/build_essential_spec.rb b/spec/unit/resource/build_essential_spec.rb
index 0043b08a5c..ae81da7503 100644
--- a/spec/unit/resource/build_essential_spec.rb
+++ b/spec/unit/resource/build_essential_spec.rb
@@ -19,7 +19,19 @@ require "spec_helper"
describe Chef::Resource::BuildEssential do
- let(:resource) { Chef::Resource::BuildEssential.new("foo") }
+ let(:node) { Chef::Node.new }
+ let(:events) { Chef::EventDispatch::Dispatcher.new }
+ let(:run_context) { Chef::RunContext.new(node, {}, events) }
+ let(:resource) { Chef::Resource::BuildEssential.new("foo", run_context) }
+ let(:provider) { resource.provider_for_action(:install) }
+
+ let(:pkgutil_cli_exists) do
+ double("shell_out", stdout: "com.apple.pkg.CLTools_Executables", exitstatus: 0, error?: false)
+ end
+
+ let(:pkgutil_cli_doesnt_exist) do
+ double("shell_out", exitstatus: 1, error?: true)
+ end
it "has a resource name of :build_essential" do
expect(resource.resource_name).to eql(:build_essential)
@@ -40,4 +52,16 @@ describe Chef::Resource::BuildEssential do
expect(resource.name).to eql("")
end
end
+
+ describe "#xcode_cli_installed?" do
+ it "returns true if the pkgutil lists the package" do
+ allow(provider).to receive(:shell_out).with("pkgutil", "--pkgs=com.apple.pkg.CLTools_Executables").and_return(pkgutil_cli_exists)
+ expect(provider.xcode_cli_installed?).to eql(true)
+ end
+
+ it "returns false if the pkgutil doesn't list the package" do
+ allow(provider).to receive(:shell_out).with("pkgutil", "--pkgs=com.apple.pkg.CLTools_Executables").and_return(pkgutil_cli_doesnt_exist)
+ expect(provider.xcode_cli_installed?).to eql(false)
+ end
+ end
end