summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/data/root_alias_cookbooks/dup_attr/attributes.rb (renamed from spec/data/cookbooks/aliased/attributes.rb)0
-rw-r--r--spec/data/root_alias_cookbooks/dup_attr/attributes/default.rb1
-rw-r--r--spec/data/root_alias_cookbooks/dup_attr/metadata.rb2
-rw-r--r--spec/data/root_alias_cookbooks/dup_attr/recipe.rb (renamed from spec/data/cookbooks/aliased/recipe.rb)0
-rw-r--r--spec/data/root_alias_cookbooks/dup_recipe/attributes.rb1
-rw-r--r--spec/data/root_alias_cookbooks/dup_recipe/metadata.rb2
-rw-r--r--spec/data/root_alias_cookbooks/dup_recipe/recipe.rb3
-rw-r--r--spec/data/root_alias_cookbooks/dup_recipe/recipes/default.rb3
-rw-r--r--spec/data/root_alias_cookbooks/simple/attributes.rb1
-rw-r--r--spec/data/root_alias_cookbooks/simple/metadata.rb (renamed from spec/data/cookbooks/aliased/metadata.rb)2
-rw-r--r--spec/data/root_alias_cookbooks/simple/recipe.rb3
-rw-r--r--spec/functional/root_alias_spec.rb28
-rw-r--r--spec/unit/cookbook_loader_spec.rb2
13 files changed, 42 insertions, 6 deletions
diff --git a/spec/data/cookbooks/aliased/attributes.rb b/spec/data/root_alias_cookbooks/dup_attr/attributes.rb
index 3a3bab96e1..3a3bab96e1 100644
--- a/spec/data/cookbooks/aliased/attributes.rb
+++ b/spec/data/root_alias_cookbooks/dup_attr/attributes.rb
diff --git a/spec/data/root_alias_cookbooks/dup_attr/attributes/default.rb b/spec/data/root_alias_cookbooks/dup_attr/attributes/default.rb
new file mode 100644
index 0000000000..a6f6c78bb0
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/dup_attr/attributes/default.rb
@@ -0,0 +1 @@
+default["aliased"]["attr"] = "other"
diff --git a/spec/data/root_alias_cookbooks/dup_attr/metadata.rb b/spec/data/root_alias_cookbooks/dup_attr/metadata.rb
new file mode 100644
index 0000000000..703a73ab19
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/dup_attr/metadata.rb
@@ -0,0 +1,2 @@
+name "dup_attr"
+version "1.0.0"
diff --git a/spec/data/cookbooks/aliased/recipe.rb b/spec/data/root_alias_cookbooks/dup_attr/recipe.rb
index d82e58fbcd..d82e58fbcd 100644
--- a/spec/data/cookbooks/aliased/recipe.rb
+++ b/spec/data/root_alias_cookbooks/dup_attr/recipe.rb
diff --git a/spec/data/root_alias_cookbooks/dup_recipe/attributes.rb b/spec/data/root_alias_cookbooks/dup_recipe/attributes.rb
new file mode 100644
index 0000000000..3a3bab96e1
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/dup_recipe/attributes.rb
@@ -0,0 +1 @@
+default["aliased"]["attr"] = "value"
diff --git a/spec/data/root_alias_cookbooks/dup_recipe/metadata.rb b/spec/data/root_alias_cookbooks/dup_recipe/metadata.rb
new file mode 100644
index 0000000000..62273a64d5
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/dup_recipe/metadata.rb
@@ -0,0 +1,2 @@
+name "dup_recipe"
+version "1.0.0"
diff --git a/spec/data/root_alias_cookbooks/dup_recipe/recipe.rb b/spec/data/root_alias_cookbooks/dup_recipe/recipe.rb
new file mode 100644
index 0000000000..d82e58fbcd
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/dup_recipe/recipe.rb
@@ -0,0 +1,3 @@
+ruby_block "root alias" do
+ block { }
+end
diff --git a/spec/data/root_alias_cookbooks/dup_recipe/recipes/default.rb b/spec/data/root_alias_cookbooks/dup_recipe/recipes/default.rb
new file mode 100644
index 0000000000..3eb7c22809
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/dup_recipe/recipes/default.rb
@@ -0,0 +1,3 @@
+ruby_block "other" do
+ block { }
+end
diff --git a/spec/data/root_alias_cookbooks/simple/attributes.rb b/spec/data/root_alias_cookbooks/simple/attributes.rb
new file mode 100644
index 0000000000..3a3bab96e1
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/simple/attributes.rb
@@ -0,0 +1 @@
+default["aliased"]["attr"] = "value"
diff --git a/spec/data/cookbooks/aliased/metadata.rb b/spec/data/root_alias_cookbooks/simple/metadata.rb
index e3b2b96177..9147558459 100644
--- a/spec/data/cookbooks/aliased/metadata.rb
+++ b/spec/data/root_alias_cookbooks/simple/metadata.rb
@@ -1,2 +1,2 @@
-name "aliased"
+name "simple"
version "1.0.0"
diff --git a/spec/data/root_alias_cookbooks/simple/recipe.rb b/spec/data/root_alias_cookbooks/simple/recipe.rb
new file mode 100644
index 0000000000..d82e58fbcd
--- /dev/null
+++ b/spec/data/root_alias_cookbooks/simple/recipe.rb
@@ -0,0 +1,3 @@
+ruby_block "root alias" do
+ block { }
+end
diff --git a/spec/functional/root_alias_spec.rb b/spec/functional/root_alias_spec.rb
index e26f41ff67..7091615d12 100644
--- a/spec/functional/root_alias_spec.rb
+++ b/spec/functional/root_alias_spec.rb
@@ -18,7 +18,7 @@
require "spec_helper"
describe "root aliases" do
- let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) }
+ let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "root_alias_cookbooks")) }
let(:cookbook_collection) do
cl = Chef::CookbookLoader.new(chef_repo_path)
cl.load_cookbooks
@@ -26,7 +26,6 @@ describe "root aliases" do
end
let(:node) do
node = Chef::Node.new
- node.run_list << "aliased"
node.automatic[:recipes] = []
node
end
@@ -38,21 +37,42 @@ describe "root aliases" do
describe "attributes root aliases" do
it "should load attributes.rb when included directly" do
- node.include_attribute("aliased")
+ node.include_attribute("simple")
expect(node["aliased"]["attr"]).to eq "value"
end
it "should load attributes.rb when loading a cookbook" do
+ node.run_list << "simple"
run_context.load(node.run_list.expand("_default"))
expect(node["aliased"]["attr"]).to eq "value"
end
+
+ context "with both an attributes.rb and attributes/default.rb" do
+ it "should log an error and ignore attributes/default.rb" do
+ expect(Chef::Log).to receive(:error).with("Cookbook dup_attr contains both attributes.rb and and attributes/default.rb, ignoring attributes/default.rb")
+ node.run_list << "dup_attr"
+ run_context.load(node.run_list.expand("_default"))
+ expect(node["aliased"]["attr"]).to eq "value"
+ end
+ end
end
describe "recipe root aliased" do
it "should load recipe.rb" do
+ node.run_list << "simple"
run_context.load(node.run_list.expand("_default"))
- run_context.include_recipe("aliased")
+ run_context.include_recipe("simple")
expect(run_context.resource_collection.map(&:to_s)).to eq ["ruby_block[root alias]"]
end
+
+ context "with both an recipe.rb and recipes/default.rb" do
+ it "should log an error and ignore recipes/default.rb" do
+ expect(Chef::Log).to receive(:error).with("Cookbook dup_recipe contains both recipe.rb and and recipes/default.rb, ignoring recipes/default.rb")
+ node.run_list << "dup_recipe"
+ run_context.load(node.run_list.expand("_default"))
+ run_context.include_recipe("dup_recipe")
+ expect(run_context.resource_collection.map(&:to_s)).to eq ["ruby_block[root alias]"]
+ end
+ end
end
end
diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb
index a7602da3b4..a5fb622da0 100644
--- a/spec/unit/cookbook_loader_spec.rb
+++ b/spec/unit/cookbook_loader_spec.rb
@@ -99,7 +99,7 @@ describe Chef::CookbookLoader do
cookbook_loader.each do |cookbook_name, cookbook|
seen << cookbook_name
end
- expect(seen).to eq %w{aliased angrybash apache2 borken ignorken java name-mismatch openldap preseed supports-platform-constraints}
+ expect(seen).to eq %w{angrybash apache2 borken ignorken java name-mismatch openldap preseed supports-platform-constraints}
end
end