diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-12-15 10:35:04 -0800 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2014-12-15 10:35:04 -0800 |
commit | a39c59dcb83fe85b2177d7501050c95109276ad3 (patch) | |
tree | 01e5211b01319eb69ef804980186eedbba6926b8 | |
parent | ed93756f31aa062067bfc1ca5f6c67fb467c637a (diff) | |
parent | 0bc237e655f45187de005db6e750e0c4a640fc51 (diff) | |
download | chef-a39c59dcb83fe85b2177d7501050c95109276ad3.tar.gz |
Merge pull request #2637 from opscode/jdm/issue-2626-rebase
Jdm/issue 2626 rebase
-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 |