diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2017-04-05 10:37:26 -0700 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2017-04-05 10:37:26 -0700 |
commit | 737bdca4a68c8abf66cec82bb7d1bb360a7ab18e (patch) | |
tree | 983d7c6095ae06c0d630fdac60c6dd6d38f6d0bb /spec | |
parent | 0c93ce6f5006eec985bcdf38124ee7390962ec4b (diff) | |
parent | 0d422fed39f8a108512e91e5f75de856a62bdac7 (diff) | |
download | chef-737bdca4a68c8abf66cec82bb7d1bb360a7ab18e.tar.gz |
Merge branch 'master' into always-inline
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/data/cookbooks/aliased/attributes.rb | 1 | ||||
-rw-r--r-- | spec/data/cookbooks/aliased/metadata.rb | 2 | ||||
-rw-r--r-- | spec/data/cookbooks/aliased/recipe.rb | 3 | ||||
-rw-r--r-- | spec/functional/root_alias_spec.rb | 58 | ||||
-rw-r--r-- | spec/unit/cookbook_loader_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/data_bag_item_spec.rb | 4 |
6 files changed, 69 insertions, 7 deletions
diff --git a/spec/data/cookbooks/aliased/attributes.rb b/spec/data/cookbooks/aliased/attributes.rb new file mode 100644 index 0000000000..3a3bab96e1 --- /dev/null +++ b/spec/data/cookbooks/aliased/attributes.rb @@ -0,0 +1 @@ +default["aliased"]["attr"] = "value" diff --git a/spec/data/cookbooks/aliased/metadata.rb b/spec/data/cookbooks/aliased/metadata.rb new file mode 100644 index 0000000000..e3b2b96177 --- /dev/null +++ b/spec/data/cookbooks/aliased/metadata.rb @@ -0,0 +1,2 @@ +name "aliased" +version "1.0.0" diff --git a/spec/data/cookbooks/aliased/recipe.rb b/spec/data/cookbooks/aliased/recipe.rb new file mode 100644 index 0000000000..d82e58fbcd --- /dev/null +++ b/spec/data/cookbooks/aliased/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 new file mode 100644 index 0000000000..e26f41ff67 --- /dev/null +++ b/spec/functional/root_alias_spec.rb @@ -0,0 +1,58 @@ +# +# Copyright:: Copyright 2017, Noah Kantrowitz +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require "spec_helper" + +describe "root aliases" do + let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) } + let(:cookbook_collection) do + cl = Chef::CookbookLoader.new(chef_repo_path) + cl.load_cookbooks + Chef::CookbookCollection.new(cl) + end + let(:node) do + node = Chef::Node.new + node.run_list << "aliased" + node.automatic[:recipes] = [] + node + end + let(:events) { Chef::EventDispatch::Dispatcher.new } + let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) } + before do + node.run_context = run_context + end + + describe "attributes root aliases" do + it "should load attributes.rb when included directly" do + node.include_attribute("aliased") + expect(node["aliased"]["attr"]).to eq "value" + end + + it "should load attributes.rb when loading a cookbook" do + run_context.load(node.run_list.expand("_default")) + expect(node["aliased"]["attr"]).to eq "value" + end + end + + describe "recipe root aliased" do + it "should load recipe.rb" do + run_context.load(node.run_list.expand("_default")) + run_context.include_recipe("aliased") + expect(run_context.resource_collection.map(&:to_s)).to eq ["ruby_block[root alias]"] + end + end +end diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb index dd731b53d3..a7602da3b4 100644 --- a/spec/unit/cookbook_loader_spec.rb +++ b/spec/unit/cookbook_loader_spec.rb @@ -99,13 +99,7 @@ describe Chef::CookbookLoader do cookbook_loader.each do |cookbook_name, cookbook| seen << cookbook_name end - expect(seen[0]).to eq("angrybash") - expect(seen[1]).to eq("apache2") - expect(seen[2]).to eq("borken") - expect(seen[3]).to eq("ignorken") - expect(seen[4]).to eq("java") - expect(seen[5]).to eq("name-mismatch") - expect(seen[6]).to eq("openldap") + expect(seen).to eq %w{aliased angrybash apache2 borken ignorken java name-mismatch openldap preseed supports-platform-constraints} end end diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index e83f0ca0ec..7094a7b1f7 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -52,6 +52,10 @@ describe Chef::DataBagItem do expect { data_bag_item.raw_data = { "id" => "octahedron" } }.not_to raise_error end + it "should let you set the raw_data with a hash containing symbols" do + expect { data_bag_item.raw_data = { :id => "octahedron" } }.not_to raise_error + end + it "should let you set the raw_data from a mash" do expect { data_bag_item.raw_data = Mash.new({ "id" => "octahedron" }) }.not_to raise_error end |