summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2017-04-05 10:37:26 -0700
committerNoah Kantrowitz <noah@coderanger.net>2017-04-05 10:37:26 -0700
commit737bdca4a68c8abf66cec82bb7d1bb360a7ab18e (patch)
tree983d7c6095ae06c0d630fdac60c6dd6d38f6d0bb
parent0c93ce6f5006eec985bcdf38124ee7390962ec4b (diff)
parent0d422fed39f8a108512e91e5f75de856a62bdac7 (diff)
downloadchef-737bdca4a68c8abf66cec82bb7d1bb360a7ab18e.tar.gz
Merge branch 'master' into always-inline
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--CHANGELOG.md6
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock60
-rw-r--r--MAINTAINERS.md1
-rw-r--r--MAINTAINERS.toml9
-rw-r--r--RELEASE_NOTES.md6
-rw-r--r--VERSION2
-rw-r--r--acceptance/data-collector/.acceptance/data-collector-test/metadata.rb2
-rw-r--r--chef-config/lib/chef-config/version.rb2
-rw-r--r--lib/chef/cookbook_version.rb17
-rw-r--r--lib/chef/data_bag_item.rb3
-rw-r--r--lib/chef/knife/cookbook_create.rb6
-rw-r--r--lib/chef/run_context/cookbook_compiler.rb17
-rw-r--r--lib/chef/version.rb2
-rw-r--r--omnibus/Gemfile.lock16
-rw-r--r--omnibus/config/software/chef-gem-inspec.rb10
-rw-r--r--omnibus/config/software/chef.rb1
-rw-r--r--spec/data/cookbooks/aliased/attributes.rb1
-rw-r--r--spec/data/cookbooks/aliased/metadata.rb2
-rw-r--r--spec/data/cookbooks/aliased/recipe.rb3
-rw-r--r--spec/functional/root_alias_spec.rb58
-rw-r--r--spec/unit/cookbook_loader_spec.rb8
-rw-r--r--spec/unit/data_bag_item_spec.rb4
23 files changed, 191 insertions, 46 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15484cc944..9719961af5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,7 @@
This changelog reflects the current state of chef's master branch on github and may not reflect the current released version of chef, which is [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef).
-## [v13.0.97](https://github.com/chef/chef/tree/v13.0.97) (2017-04-04)
-[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.97)
+## [v13.0.102](https://github.com/chef/chef/tree/v13.0.102) (2017-04-05)
+[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.102)
**Merged pull requests:**
@@ -53,8 +53,6 @@ This changelog reflects the current state of chef's master branch on github and
- Chef-13: remove method\_missing access to node object. [\#5895](https://github.com/chef/chef/pull/5895) ([lamont-granquist](https://github.com/lamont-granquist))
- Avoid a double get in chef\_fs [\#5890](https://github.com/chef/chef/pull/5890) ([jeremymv2](https://github.com/jeremymv2))
- Prevent content expansion of the bootstrap command in the option --json-attributes [\#5888](https://github.com/chef/chef/pull/5888) ([afiune](https://github.com/afiune))
-- Compress debs and rpms with xz [\#5884](https://github.com/chef/chef/pull/5884) ([thommay](https://github.com/thommay))
-- Chef-13: Chef::Resource cleanup [\#5882](https://github.com/chef/chef/pull/5882) ([lamont-granquist](https://github.com/lamont-granquist))
## [v12.19.33](https://github.com/chef/chef/tree/v12.19.33) (2017-02-16)
[Full Changelog](https://github.com/chef/chef/compare/v12.18.31...v12.19.33)
diff --git a/Gemfile b/Gemfile
index 343c1f3f9f..cdcfb23f26 100644
--- a/Gemfile
+++ b/Gemfile
@@ -22,6 +22,7 @@ gem "cheffish", "~> 13" # required for rspec tests
group(:omnibus_package) do
gem "appbundler"
gem "rb-readline"
+ gem "inspec"
# nokogiri has no ruby-2.4 version for windows so it cannot go into our Gemfile.lock
# gem "nokogiri", ">= 1.7.1"
end
diff --git a/Gemfile.lock b/Gemfile.lock
index da35692c86..9ccd05baa5 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/chef/chef-server
- revision: b670bd5f2ed1f56a39ab0c211efd4204b6978422
+ revision: 07fea253ceea254af8fbd9c602a04017751cae21
specs:
oc-chef-pedant (2.2.0)
activesupport (>= 4.2.7.1, < 6.0)
@@ -37,7 +37,7 @@ GIT
GIT
remote: https://github.com/chef/ohai.git
- revision: 21cc711810e860d9db378f39da88406eec48d878
+ revision: 6bb6e8cf30118b104dbcffaea17ffb1644aee2cc
specs:
ohai (13.0.0)
chef-config (>= 12.5.0.alpha.1, < 14)
@@ -113,10 +113,10 @@ GIT
PATH
remote: .
specs:
- chef (13.0.98)
+ chef (13.0.103)
addressable
bundler (>= 1.10)
- chef-config (= 13.0.98)
+ chef-config (= 13.0.103)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -142,10 +142,10 @@ PATH
specinfra (~> 2.10)
syslog-logger (~> 1.6)
uuidtools (~> 2.1.5)
- chef (13.0.98-universal-mingw32)
+ chef (13.0.103-universal-mingw32)
addressable
bundler (>= 1.10)
- chef-config (= 13.0.98)
+ chef-config (= 13.0.103)
chef-zero (>= 13.0)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
@@ -186,7 +186,7 @@ PATH
PATH
remote: chef-config
specs:
- chef-config (13.0.98)
+ chef-config (13.0.103)
addressable
fuzzyurl
mixlib-config (~> 2.0)
@@ -205,17 +205,18 @@ GEM
mixlib-cli (~> 1.4)
artifactory (2.8.1)
ast (2.3.0)
- aws-sdk (2.9.2)
- aws-sdk-resources (= 2.9.2)
- aws-sdk-core (2.9.2)
+ aws-sdk (2.9.3)
+ aws-sdk-resources (= 2.9.3)
+ aws-sdk-core (2.9.3)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.9.2)
- aws-sdk-core (= 2.9.2)
+ aws-sdk-resources (2.9.3)
+ aws-sdk-core (= 2.9.3)
aws-sigv4 (1.0.0)
backports (3.7.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
+ blankslate (2.1.2.4)
builder (3.2.3)
byebug (9.0.6)
chef-api (0.7.0)
@@ -257,6 +258,9 @@ GEM
debug_inspector (0.0.2)
diff-lcs (1.3)
docile (1.1.5)
+ docker-api (1.33.3)
+ excon (>= 0.38.0)
+ json
domain_name (0.5.20170223)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
@@ -309,6 +313,23 @@ GEM
httpclient (2.8.3)
i18n (0.8.1)
iniparse (1.4.2)
+ inspec (1.19.1)
+ addressable (~> 2.4)
+ faraday (>= 0.9.0)
+ hashie (~> 3.4)
+ json (>= 1.8, < 3.0)
+ method_source (~> 0.8)
+ mixlib-log
+ parallel (~> 1.9)
+ pry (~> 0)
+ rainbow (~> 2)
+ rspec (~> 3)
+ rspec-its (~> 1.2)
+ rubyzip (~> 1.1)
+ sslshake (~> 1)
+ thor (~> 0.19)
+ toml (~> 0.1)
+ train (>= 0.22.0, < 1.0)
ipaddress (0.8.3)
jmespath (1.3.1)
json (2.0.3)
@@ -384,8 +405,11 @@ GEM
nori (2.6.0)
octokit (4.6.2)
sawyer (~> 0.8.0, >= 0.5.3)
+ parallel (1.11.1)
parser (2.4.0.0)
ast (~> 2.2)
+ parslet (1.5.0)
+ blankslate (~> 2.0)
plist (3.2.0)
poise-profiler (1.0.1)
halite (~> 1.0)
@@ -477,6 +501,7 @@ GEM
net-ssh (>= 2.7, < 5.0)
net-telnet
sfl
+ sslshake (1.1.0)
stove (5.1.0)
chef-api (~> 0.5)
logify (~> 0.2)
@@ -492,7 +517,17 @@ GEM
thor (~> 0.19, < 0.19.2)
thor (0.19.1)
thread_safe (0.3.6)
+ toml (0.1.2)
+ parslet (~> 1.5.0)
tomlrb (1.2.4)
+ train (0.23.0)
+ docker-api (~> 1.26)
+ json (>= 1.8, < 3.0)
+ mixlib-shellout (~> 2.0)
+ net-scp (~> 1.2)
+ net-ssh (>= 2.9, < 5.0)
+ winrm (~> 2.0)
+ winrm-fs (~> 1.0)
travis (1.8.8)
backports
faraday (~> 0.9)
@@ -578,6 +613,7 @@ DEPENDENCIES
foodcritic
github_changelog_generator!
halite!
+ inspec
knife-windows
mixlib-install
netrc
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index c87879ac16..ae689483c7 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -46,6 +46,7 @@ To mention the team, use @chef/client-core
* [Tim Smith](https://github.com/tas50)
* [Tom Duffield](https://github.com/tduffield)
* [Tyler Ball](https://github.com/tyler-ball)
+* [Josh Hudson](https://github.com/itmustbejj)
## Chef Provisioning
diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml
index 10e7655cd8..83de2c6bc6 100644
--- a/MAINTAINERS.toml
+++ b/MAINTAINERS.toml
@@ -51,7 +51,8 @@ Maintainers for the Chef client, Ohai, mixlibs, ChefDK, ChefSpec, Foodcritic, ch
"stevendanna",
"tas50",
"tduffield",
- "tyler-ball"
+ "tyler-ball",
+ "itmustbejj"
]
[Org.Components.Provisioning]
@@ -366,3 +367,9 @@ The specific components of Chef related to a given platform - including (but not
GitHub = "mikedodge04"
Twitter = "mikedodge04"
IRC = "mikedodge04"
+
+ [people.itmustbejj]
+ Name = "Josh Hudson"
+ GitHub = "itmustbejj"
+ Twitter = "itmustbejj"
+ IRC = "itmustbejj"
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 3789eb567f..b16550b8e6 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -258,6 +258,12 @@ The behavior of the `clear_sources` property is now to only add `--clear-sources
Please use `knife cookbook site install` instead.
+### Cookbook root aliases
+
+Rather than `attributes/default.rb`, cookbooks can now use `attributes.rb` in
+the root of the cookbook. Similarly for a single default recipe, cookbooks can
+use `recipe.rb` in the root of the cookbook.
+
### `use_inline_resources` is always enabled
The `use_inline_resources` provider mode is always enabled when using the
diff --git a/VERSION b/VERSION
index 674934e373..f1698a3b3d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-13.0.98 \ No newline at end of file
+13.0.103 \ No newline at end of file
diff --git a/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb b/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb
index dbd376aa83..34402c8af1 100644
--- a/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb
+++ b/acceptance/data-collector/.acceptance/data-collector-test/metadata.rb
@@ -1,7 +1,7 @@
name 'data-collector-test'
maintainer 'Adam Leff'
maintainer_email 'adamleff@chef.io'
-license 'Apache 2.0'
+license 'Apache-2.0'
description 'Installs/Configures data-collector-test'
long_description 'Installs/Configures data-collector-test'
version '0.1.0'
diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb
index 95dd1d3b36..be62082d1e 100644
--- a/chef-config/lib/chef-config/version.rb
+++ b/chef-config/lib/chef-config/version.rb
@@ -21,7 +21,7 @@
module ChefConfig
CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "13.0.98"
+ VERSION = "13.0.103"
end
#
diff --git a/lib/chef/cookbook_version.rb b/lib/chef/cookbook_version.rb
index 738f98929e..dcb8c97548 100644
--- a/lib/chef/cookbook_version.rb
+++ b/lib/chef/cookbook_version.rb
@@ -134,11 +134,24 @@ class Chef
end
def attribute_filenames_by_short_filename
- @attribute_filenames_by_short_filename ||= filenames_by_name(files_for("attributes"))
+ @attribute_filenames_by_short_filename ||= begin
+ name_map = filenames_by_name(files_for("attributes"))
+ root_alias = cookbook_manifest.root_files.find { |record| record[:name] == "attributes.rb" }
+ name_map["default"] = root_alias[:full_path] if root_alias
+ name_map
+ end
end
def recipe_filenames_by_name
- @recipe_filenames_by_name ||= filenames_by_name(files_for("recipes"))
+ @recipe_filenames_by_name ||= begin
+ name_map = filenames_by_name(files_for("recipes"))
+ root_alias = cookbook_manifest.root_files.find { |record| record[:name] == "recipe.rb" }
+ if root_alias
+ Chef::Log.error("Cookbook #{name} contains both recipe.rb and and recipes/default.rb, ignoring recipes/default.rb") if name_map["default"]
+ name_map["default"] = root_alias[:full_path]
+ end
+ name_map
+ end
end
def metadata=(metadata)
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb
index ddb520dc0b..d0fca26125 100644
--- a/lib/chef/data_bag_item.rb
+++ b/lib/chef/data_bag_item.rb
@@ -75,6 +75,7 @@ class Chef
end
def raw_data=(new_data)
+ new_data = Mash.new(new_data)
unless new_data.respond_to?(:[]) && new_data.respond_to?(:keys)
raise Exceptions::ValidationFailed, "Data Bag Items must contain a Hash or Mash!"
end
@@ -132,7 +133,7 @@ class Chef
item = new
item.data_bag(h.delete("data_bag")) if h.key?("data_bag")
if h.key?("raw_data")
- item.raw_data = Mash.new(h["raw_data"])
+ item.raw_data = h["raw_data"]
else
item.raw_data = h
end
diff --git a/lib/chef/knife/cookbook_create.rb b/lib/chef/knife/cookbook_create.rb
index ccb78bb7a6..745e413144 100644
--- a/lib/chef/knife/cookbook_create.rb
+++ b/lib/chef/knife/cookbook_create.rb
@@ -418,11 +418,11 @@ EOH
license_name = case license
when "apachev2"
- "Apache 2.0"
+ "Apache-2.0"
when "gplv2"
- "GNU Public License 2.0"
+ "GPL-2.0"
when "gplv3"
- "GNU Public License 3.0"
+ "GPL-3.0"
when "mit"
"MIT"
when "none"
diff --git a/lib/chef/run_context/cookbook_compiler.rb b/lib/chef/run_context/cookbook_compiler.rb
index 94635be03d..ea5931ac75 100644
--- a/lib/chef/run_context/cookbook_compiler.rb
+++ b/lib/chef/run_context/cookbook_compiler.rb
@@ -105,7 +105,7 @@ class Chef
# according to #cookbook_order; within a cookbook, +default.rb+ is loaded
# first, then the remaining attributes files in lexical sort order.
def compile_attributes
- @events.attribute_load_start(count_files_by_segment(:attributes))
+ @events.attribute_load_start(count_files_by_segment(:attributes, "attributes.rb"))
cookbook_order.each do |cookbook|
load_attributes_from_cookbook(cookbook)
end
@@ -166,7 +166,16 @@ class Chef
def load_attributes_from_cookbook(cookbook_name)
list_of_attr_files = files_in_cookbook_by_segment(cookbook_name, :attributes).dup
- if default_file = list_of_attr_files.find { |path| File.basename(path) == "default.rb" }
+ root_alias = cookbook_collection[cookbook_name].files_for(:root_files).find { |record| record[:name] == "attributes.rb" }
+ default_file = list_of_attr_files.find { |path| File.basename(path) == "default.rb" }
+ if root_alias
+ if default_file
+ Chef::Log.error("Cookbook #{cookbook_name} contains both attributes.rb and and attributes/default.rb, ignoring attributes/default.rb")
+ list_of_attr_files.delete(default_file)
+ end
+ # The actual root_alias path decoding is handled in CookbookVersion#attribute_filenames_by_short_filename
+ load_attribute_file(cookbook_name.to_s, "default")
+ elsif default_file
list_of_attr_files.delete(default_file)
load_attribute_file(cookbook_name.to_s, default_file)
end
@@ -259,9 +268,9 @@ class Chef
ordered_cookbooks << cookbook
end
- def count_files_by_segment(segment)
+ def count_files_by_segment(segment, root_alias = nil)
cookbook_collection.inject(0) do |count, cookbook_by_name|
- count + cookbook_by_name[1].segment_filenames(segment).size
+ count + cookbook_by_name[1].segment_filenames(segment).size + (root_alias ? cookbook_by_name[1].files_for(:root_files).select { |record| record[:name] == root_alias }.size : 0)
end
end
diff --git a/lib/chef/version.rb b/lib/chef/version.rb
index 1014b5a06f..8f72d79cfb 100644
--- a/lib/chef/version.rb
+++ b/lib/chef/version.rb
@@ -21,7 +21,7 @@
class Chef
CHEF_ROOT = File.expand_path("../..", __FILE__)
- VERSION = "13.0.98"
+ VERSION = "13.0.103"
end
#
diff --git a/omnibus/Gemfile.lock b/omnibus/Gemfile.lock
index a3441fa454..6123bb1b22 100644
--- a/omnibus/Gemfile.lock
+++ b/omnibus/Gemfile.lock
@@ -8,7 +8,7 @@ GIT
GIT
remote: https://github.com/chef/omnibus
- revision: 433220e0b7c434dbc4a36daaa1fecbdb1bf7231d
+ revision: dae5821c972ad37716f852767bc8ec7919730600
specs:
omnibus (5.5.0)
aws-sdk (~> 2)
@@ -25,7 +25,7 @@ GIT
GIT
remote: https://github.com/chef/omnibus-software
- revision: fee8dea479123a3b19b14244eeee0f8e36579107
+ revision: 7a9182b313ca767a0d286e0db337cc61a6e621a3
specs:
omnibus-software (4.0.0)
chef-sugar (>= 3.4.0)
@@ -38,13 +38,13 @@ GEM
public_suffix (~> 2.0, >= 2.0.2)
artifactory (2.8.1)
awesome_print (1.7.0)
- aws-sdk (2.9.1)
- aws-sdk-resources (= 2.9.1)
- aws-sdk-core (2.9.1)
+ aws-sdk (2.9.3)
+ aws-sdk-resources (= 2.9.3)
+ aws-sdk-core (2.9.3)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
- aws-sdk-resources (2.9.1)
- aws-sdk-core (= 2.9.1)
+ aws-sdk-resources (2.9.3)
+ aws-sdk-core (= 2.9.3)
aws-sigv4 (1.0.0)
berkshelf (4.3.5)
addressable (~> 2.3, >= 2.3.4)
@@ -231,7 +231,7 @@ GEM
hashie (>= 2.0.2, < 4.0.0)
win32-process (0.8.3)
ffi (>= 1.0.0)
- winrm (2.1.3)
+ winrm (2.2.1)
builder (>= 2.1.2)
erubis (~> 2.7)
gssapi (~> 1.2)
diff --git a/omnibus/config/software/chef-gem-inspec.rb b/omnibus/config/software/chef-gem-inspec.rb
new file mode 100644
index 0000000000..8c5e1cbf26
--- /dev/null
+++ b/omnibus/config/software/chef-gem-inspec.rb
@@ -0,0 +1,10 @@
+# gem installs this gem from the version specified in chef's Gemfile.lock
+# so we can take advantage of omnibus's caching. Just duplicate this file and
+# add the new software def to chef software def if you want to separate
+# another gem's installation.
+require_relative "../../files/chef-gem/build-chef-gem/gem-install-software-def"
+BuildChefGem::GemInstallSoftwareDef.define(self, __FILE__)
+
+license "Apache-2.0"
+license_file "https://raw.githubusercontent.com/chef/inspec/master/LICENSE"
+skip_transitive_dependency_licensing true
diff --git a/omnibus/config/software/chef.rb b/omnibus/config/software/chef.rb
index 6130b3d74c..4726f8b687 100644
--- a/omnibus/config/software/chef.rb
+++ b/omnibus/config/software/chef.rb
@@ -44,6 +44,7 @@ dependency "chef-gem-ruby-prof"
dependency "chef-gem-byebug"
dependency "chef-gem-debug_inspector"
dependency "chef-gem-binding_of_caller"
+dependency "chef-gem-inspec"
unless ios_xr? || solaris?
dependency "chef-gem-rbnacl-libsodium"
dependency "chef-gem-bcrypt_pbkdf-ruby"
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