summaryrefslogtreecommitdiff
path: root/spec/unit/recipe_spec.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2014-03-13 21:12:29 -0700
committerdanielsdeleo <dan@getchef.com>2014-03-14 14:09:37 -0700
commitbecb0427f813f787fd492798f6c97de67fdd732c (patch)
treeea01bc7e6ee4860eee8111c2fa9a3a382c891207 /spec/unit/recipe_spec.rb
parent8c2a9753bdf8ee43226082825eb0a0531c94e202 (diff)
downloadchef-becb0427f813f787fd492798f6c97de67fdd732c.tar.gz
Raise an error when including a recipe from an unreachable cookbook
Fixes CHEF-4367. When attempting to load a recipe belonging to a cookbook that is not in the run_list or any dependencies of cookbooks in the run_list, chef will now produce an error like this: Chef::Exceptions::MissingCookbookDependency ------------------------------------------- Recipe `ancient::aliens` is not in the run_list, and cookbook 'ancient' is not a dependency of any cookbook in the run_list. To load thisrecipe, first add a dependency on cookbook 'ancient' in the cookbook you're including it from in that cookbook's metadata. This error will occur when chef-solo users use `include_recipe` without specifying the dependency in metadata; prior to this patch, chef would typically fail reading an undefined attribute, which commonly would result in a NoMethodError for nil.
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r--spec/unit/recipe_spec.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index b0cd04b245..2bdf470143 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -339,6 +339,7 @@ describe Chef::Recipe do
describe "include_recipe" do
it "should evaluate another recipe with include_recipe" do
node.should_receive(:loaded_recipe).with(:openldap, "gigantor")
+ run_context.stub(:unreachable_cookbook?).with(:openldap).and_return(false)
run_context.include_recipe "openldap::gigantor"
res = run_context.resource_collection.resources(:cat => "blanket")
res.name.should eql("blanket")
@@ -347,6 +348,7 @@ describe Chef::Recipe do
it "should load the default recipe for a cookbook if include_recipe is called without a ::" do
node.should_receive(:loaded_recipe).with(:openldap, "default")
+ run_context.stub(:unreachable_cookbook?).with(:openldap).and_return(false)
run_context.include_recipe "openldap"
res = run_context.resource_collection.resources(:cat => "blanket")
res.name.should eql("blanket")
@@ -355,12 +357,14 @@ describe Chef::Recipe do
it "should store that it has seen a recipe in the run_context" do
node.should_receive(:loaded_recipe).with(:openldap, "default")
+ run_context.stub(:unreachable_cookbook?).with(:openldap).and_return(false)
run_context.include_recipe "openldap"
run_context.loaded_recipe?("openldap").should be_true
end
it "should not include the same recipe twice" do
node.should_receive(:loaded_recipe).with(:openldap, "default").exactly(:once)
+ run_context.stub(:unreachable_cookbook?).with(:openldap).and_return(false)
cookbook_collection[:openldap].should_receive(:load_recipe).with("default", run_context)
recipe.include_recipe "openldap"
cookbook_collection[:openldap].should_not_receive(:load_recipe).with("default", run_context)