diff options
author | Bruce Krysiak <bruce@honk.com> | 2010-11-30 20:02:21 -0800 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2011-06-07 15:41:13 -0700 |
commit | 965df49be2e88d6b764d791a80cfffe331efd4aa (patch) | |
tree | cefebc29b911b12368904ffbb5faf76402a60014 | |
parent | 95ebe905e09b3444ba4c3d756ae56245244b218f (diff) | |
download | chef-965df49be2e88d6b764d791a80cfffe331efd4aa.tar.gz |
OSX macports package provider respects options attribute
-rw-r--r-- | chef/lib/chef/provider/package/macports.rb | 8 | ||||
-rw-r--r-- | chef/spec/unit/provider/package/macports_spec.rb | 31 |
2 files changed, 35 insertions, 4 deletions
diff --git a/chef/lib/chef/provider/package/macports.rb b/chef/lib/chef/provider/package/macports.rb index ceee848f54..fd33788944 100644 --- a/chef/lib/chef/provider/package/macports.rb +++ b/chef/lib/chef/provider/package/macports.rb @@ -43,7 +43,7 @@ class Chef def install_package(name, version) unless @current_resource.version == version - command = "port install #{name}" + command = "port#{expand_options(@new_resource.options)} install #{name}" command << " @#{version}" if version and !version.empty? run_command_with_systems_locale( :command => command @@ -52,7 +52,7 @@ class Chef end def purge_package(name, version) - command = "port uninstall #{name}" + command = "port#{expand_options(@new_resource.options)} uninstall #{name}" command << " @#{version}" if version and !version.empty? run_command_with_systems_locale( :command => command @@ -60,7 +60,7 @@ class Chef end def remove_package(name, version) - command = "port deactivate #{name}" + command = "port#{expand_options(@new_resource.options)} deactivate #{name}" command << " @#{version}" if version and !version.empty? run_command_with_systems_locale( @@ -79,7 +79,7 @@ class Chef install_package(name, version) elsif current_version != version run_command_with_systems_locale( - :command => "port upgrade #{name} @#{version}" + :command => "port#{expand_options(@new_resource.options)} upgrade #{name} @#{version}" ) end end diff --git a/chef/spec/unit/provider/package/macports_spec.rb b/chef/spec/unit/provider/package/macports_spec.rb index 389e394095..46d61c0359 100644 --- a/chef/spec/unit/provider/package/macports_spec.rb +++ b/chef/spec/unit/provider/package/macports_spec.rb @@ -116,6 +116,15 @@ EOF @provider.install_package("zsh", "4.2.7") end + + it "should add options to the port command when specified" do + @current_resource.should_receive(:version).and_return("4.1.6") + @provider.current_resource = @current_resource + @new_resource.stub!(:options).and_return("-f") + @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f install zsh @4.2.7") + + @provider.install_package("zsh", "4.2.7") + end end describe "purge_package" do @@ -128,6 +137,12 @@ EOF @provider.should_receive(:run_command_with_systems_locale).with(:command => "port uninstall zsh") @provider.purge_package("zsh", nil) end + + it "should add options to the port command when specified" do + @new_resource.stub!(:options).and_return("-f") + @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f uninstall zsh @4.2.7") + @provider.purge_package("zsh", "4.2.7") + end end describe "remove_package" do @@ -140,6 +155,12 @@ EOF @provider.should_receive(:run_command_with_systems_locale).with(:command => "port deactivate zsh") @provider.remove_package("zsh", nil) end + + it "should add options to the port command when specified" do + @new_resource.stub!(:options).and_return("-f") + @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f deactivate zsh @4.2.7") + @provider.remove_package("zsh", "4.2.7") + end end describe "upgrade_package" do @@ -167,5 +188,15 @@ EOF @provider.upgrade_package("zsh", "4.2.7") end + + it "should add options to the port command when specified" do + @new_resource.stub!(:options).and_return("-f") + @current_resource.should_receive(:version).at_least(:once).and_return("4.1.6") + @provider.current_resource = @current_resource + + @provider.should_receive(:run_command_with_systems_locale).with(:command => "port -f upgrade zsh @4.2.7") + + @provider.upgrade_package("zsh", "4.2.7") + end end end |