summaryrefslogtreecommitdiff
path: root/chef
diff options
context:
space:
mode:
authorBryan McLellan <btm@opscode.com>2012-12-03 10:49:28 -0800
committerBryan McLellan <btm@opscode.com>2012-12-03 10:55:58 -0800
commiteca4fd7a08379d93e2ba60b4b6d6246f48f7c597 (patch)
tree103ddf4e9fefc32c52b176e244767d53705a802f /chef
parentc536fb710531e051572f723174361e4ef3507e66 (diff)
downloadchef-eca4fd7a08379d93e2ba60b4b6d6246f48f7c597.tar.gz
CHEF-3555: fix knife cookbook site install when String
Ensure we turn cookbook_path into an Array before calling #first on it, as this does not work in Ruby 1.9+ H/T Aaron Kalin for the fix
Diffstat (limited to 'chef')
-rw-r--r--chef/lib/chef/knife/cookbook_site_install.rb2
-rw-r--r--chef/spec/unit/knife/cookbook_site_install_spec.rb14
2 files changed, 13 insertions, 3 deletions
diff --git a/chef/lib/chef/knife/cookbook_site_install.rb b/chef/lib/chef/knife/cookbook_site_install.rb
index 584735d8ff..d7a3bfd62c 100644
--- a/chef/lib/chef/knife/cookbook_site_install.rb
+++ b/chef/lib/chef/knife/cookbook_site_install.rb
@@ -74,7 +74,7 @@ class Chef
@cookbook_name = parse_name_args!
# Check to ensure we have a valid source of cookbooks before continuing
#
- @install_path = File.expand_path(config[:cookbook_path].first)
+ @install_path = File.expand_path(Array(config[:cookbook_path]).first)
ui.info "Installing #@cookbook_name to #{@install_path}"
@repo = CookbookSCMRepo.new(@install_path, ui, config)
diff --git a/chef/spec/unit/knife/cookbook_site_install_spec.rb b/chef/spec/unit/knife/cookbook_site_install_spec.rb
index 2ec87b8d16..167ab490da 100644
--- a/chef/spec/unit/knife/cookbook_site_install_spec.rb
+++ b/chef/spec/unit/knife/cookbook_site_install_spec.rb
@@ -60,7 +60,6 @@ describe Chef::Knife::CookbookSiteInstall do
describe "run" do
-
it "should return an error if a cookbook name is not provided" do
@knife.name_args = []
@knife.ui.should_receive(:error).with("Please specify a cookbook to download and install.")
@@ -91,7 +90,6 @@ describe Chef::Knife::CookbookSiteInstall do
lambda { @knife.run }.should raise_error(SystemExit)
end
-
it "should install the specified version if second argument is a three-digit version" do
@knife.name_args = ["getting-started", "0.1.0"]
@knife.config[:no_deps] = true
@@ -134,5 +132,17 @@ describe Chef::Knife::CookbookSiteInstall do
@repo.should_not_receive(:reset_to_default_state)
@knife.run
end
+
+ it "should not raise an error if cookbook_path is a string" do
+ @knife.config[:cookbook_path] = '/var/tmp/chef'
+ @knife.config[:no_deps] = true
+ @knife.name_args = ["getting-started"]
+ upstream_file = File.join(@install_path, "getting-started.tar.gz")
+ @knife.should_receive(:download_cookbook_to).with(upstream_file)
+ @knife.should_receive(:extract_cookbook).with(upstream_file, "0.3.0")
+ @knife.should_receive(:clear_existing_files).with(File.join(@install_path, "getting-started"))
+ @repo.should_receive(:merge_updates_from).with("getting-started", "0.3.0")
+ lambda { @knife.run }.should_not raise_error
+ end
end
end