summaryrefslogtreecommitdiff
path: root/spec/unit/recipe_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-06-03 12:48:01 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-06-04 09:34:08 -0700
commite4c52e53a4b9caebebf09fb8ff944f7a2397fe33 (patch)
treecc0d295be849ff2abbbaa6d63c856c823eb7f9a0 /spec/unit/recipe_spec.rb
parent0c5556b8d1aceee30a25855a965a7ec13d8fa13b (diff)
downloadchef-e4c52e53a4b9caebebf09fb8ff944f7a2397fe33.tar.gz
allow include_recipe from LWRP provider code
allows include_recipe "build-essential" to work from provider code.
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r--spec/unit/recipe_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 618c742998..72d5cc6f63 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -578,6 +578,36 @@ describe Chef::Recipe do
expect(cookbook_collection[:openldap]).not_to receive(:load_recipe).with("default", run_context)
openldap_recipe.include_recipe "::default"
end
+
+ it "will not load a recipe twice when called first from an LWRP provider" do
+ openldap_recipe = Chef::Recipe.new("openldap", "test", run_context)
+ expect(node).to receive(:loaded_recipe).with(:openldap, "default").exactly(:once)
+ allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false)
+ expect(cookbook_collection[:openldap]).to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.include_recipe "::default"
+ expect(cookbook_collection[:openldap]).not_to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.openldap_includer("do it").run_action(:run)
+ end
+
+ it "will not load a recipe twice when called last from an LWRP provider" do
+ openldap_recipe = Chef::Recipe.new("openldap", "test", run_context)
+ expect(node).to receive(:loaded_recipe).with(:openldap, "default").exactly(:once)
+ allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false)
+ expect(cookbook_collection[:openldap]).to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.openldap_includer("do it").run_action(:run)
+ expect(cookbook_collection[:openldap]).not_to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.include_recipe "::default"
+ end
+
+ it "will not load a recipe twice when called both times from an LWRP provider" do
+ openldap_recipe = Chef::Recipe.new("openldap", "test", run_context)
+ expect(node).to receive(:loaded_recipe).with(:openldap, "default").exactly(:once)
+ allow(run_context).to receive(:unreachable_cookbook?).with(:openldap).and_return(false)
+ expect(cookbook_collection[:openldap]).to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.openldap_includer("do it").run_action(:run)
+ expect(cookbook_collection[:openldap]).not_to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.openldap_includer("do it").run_action(:run)
+ end
end
describe "tags" do