diff options
-rw-r--r-- | lib/chef/provider/package/windows/msi.rb | 2 | ||||
-rw-r--r-- | spec/unit/provider/package/windows/msi_spec.rb | 21 |
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb index cc07909d8e..e43a307cca 100644 --- a/lib/chef/provider/package/windows/msi.rb +++ b/lib/chef/provider/package/windows/msi.rb @@ -19,6 +19,7 @@ # TODO: Allow @new_resource.source to be a Product Code as a GUID for uninstall / network install require 'chef/win32/api/installer' if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +require 'chef/mixin/shell_out' class Chef class Provider @@ -26,6 +27,7 @@ class Chef class Windows class MSI include Chef::ReservedNames::Win32::API::Installer if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + include Chef::Mixin::ShellOut def initialize(resource) @new_resource = resource diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index e539bbbb79..bef202847f 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -18,13 +18,22 @@ require 'spec_helper' -describe Chef::Provider::Package::Windows::MSI, :windows_only do +describe Chef::Provider::Package::Windows::MSI do let(:node) { double('Chef::Node') } let(:events) { double('Chef::Events').as_null_object } # mock all the methods let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } let(:new_resource) { Chef::Resource::WindowsPackage.new("calculator.msi") } let(:provider) { Chef::Provider::Package::Windows::MSI.new(new_resource) } + before(:each) do + stub_const("File::ALT_SEPARATOR", "\\") + allow(::File).to receive(:absolute_path).with("calculator.msi").and_return("calculator.msi") + end + + it "responds to shell_out!" do + expect(provider).to respond_to(:shell_out!) + end + describe "expand_options" do it "returns an empty string if passed no options" do expect(provider.expand_options(nil)).to eql "" @@ -51,10 +60,16 @@ describe Chef::Provider::Package::Windows::MSI, :windows_only do end describe "install_package" do - # calls shell_out! + it "calls msiexec /qn /i" do + expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/i \"calculator.msi\"/, kind_of(Hash)) + provider.install_package("unused", "unused") + end end describe "remove_package" do - # calls shell_out! + it "calls msiexec /qn /x" do + expect(provider).to receive(:shell_out!).with(/msiexec \/qn \/x \"calculator.msi\"/, kind_of(Hash)) + provider.remove_package("unused", "unused") + end end end |