diff options
Diffstat (limited to 'spec/unit/recipe_spec.rb')
-rw-r--r-- | spec/unit/recipe_spec.rb | 20 |
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 |