diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2017-04-05 11:12:26 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2017-04-05 11:12:26 -0700 |
commit | 98583c917ce1689d2c6aa36fcf19c9dab90662e3 (patch) | |
tree | 0d38f775c33bb261ff48d3b24ddd211450ff375e /spec/functional | |
parent | 1c2355a9dfde6221642095da911f8c9679c46975 (diff) | |
download | chef-98583c917ce1689d2c6aa36fcf19c9dab90662e3.tar.gz |
Improve coverage of root alias tests.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec/functional')
-rw-r--r-- | spec/functional/root_alias_spec.rb | 28 |
1 files changed, 24 insertions, 4 deletions
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 |