summaryrefslogtreecommitdiff
path: root/spec/unit/run_context_spec.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-01-20 10:16:17 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-20 10:21:10 -0800
commit35276fd91c5aec8986723504b8a490e5823b770e (patch)
tree5ea6d3a89ebc905d816753160d290e8a76199e0b /spec/unit/run_context_spec.rb
parentb622710cd1ee8af39bc3ff255e2394c0115abaac (diff)
downloadchef-35276fd91c5aec8986723504b8a490e5823b770e.tar.gz
make include_recipe "::foo" use current cookbook
The following code is brittle if you want to fork the cookbook and rename it (which is a best practice when forking cookbooks for internal use): ```ruby if node[:platform_family] == "rhel" include_recipe "mycookbook::_rhel" end ``` In order for cookbooks to be easily renamable they can currently use the syntax `include_recipe "#{cookbook_name}::_rhel"` which is unwieldy. This patch adds `include_recipe "::_rhel"` as syntax sugar to make this easier.
Diffstat (limited to 'spec/unit/run_context_spec.rb')
-rw-r--r--spec/unit/run_context_spec.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb
index ba4f2ede68..d656111a7d 100644
--- a/spec/unit/run_context_spec.rb
+++ b/spec/unit/run_context_spec.rb
@@ -104,6 +104,11 @@ describe Chef::RunContext do
end.to raise_error(Chef::Exceptions::CookbookNotFound)
end
+ it "raises an error on a recipe with a leading :: with no current_cookbook" do
+ expect do
+ run_context.include_recipe("::aliens")
+ end.to raise_error(RuntimeError)
+ end
end
describe "querying the contents of cookbooks" do