summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-01-14 15:02:43 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-14 15:02:43 -0800
commit4f4323feb8b178878d912fe1e14331fb3a7e6d29 (patch)
treee7e9ed6020522a7321f00ce1296c60f8d14cf543
parentb00c2429388b3d1e6e77b83da3c444a14325f15b (diff)
downloadchef-lcg/default-cookbook.tar.gz
add test to show recipe singleton-ness not brokenlcg/default-cookbook
-rw-r--r--spec/unit/recipe_spec.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb
index 88fe98c734..5ade7c86e2 100644
--- a/spec/unit/recipe_spec.rb
+++ b/spec/unit/recipe_spec.rb
@@ -509,6 +509,26 @@ describe Chef::Recipe do
expect(cookbook_collection[:openldap]).to receive(:load_recipe).with("default", run_context)
openldap_recipe.include_recipe "::default"
end
+
+ it "will not include the same recipe twice when using leading :: syntax" 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.include_recipe "openldap::default"
+ end
+
+ it "will not include the same recipe twice when using leading :: syntax (reversed order)" 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 "openldap::default"
+ expect(cookbook_collection[:openldap]).not_to receive(:load_recipe).with("default", run_context)
+ openldap_recipe.include_recipe "::default"
+ end
end
describe "tags" do