summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-04-27 14:37:35 -0700
committerTim Smith <tsmith@chef.io>2018-04-27 14:37:35 -0700
commit6a012bd225aa24d14cca9ee70010a663cf733682 (patch)
treec5e52a577d48d8c4b0e2190fd7c7daac6977ace6
parenta068d3cde6105a591da24d1a5ff35bde26c16214 (diff)
downloadchef-build_name.tar.gz
Allow build_essential resource to be used without setting a namebuild_name
This is the same as apt_update. It seems odd to use this resource with a name like this: ```ruby build_essential "build-essential" ``` Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--kitchen-tests/cookbooks/base/recipes/default.rb2
-rw-r--r--lib/chef/resource/build_essential.rb3
-rw-r--r--spec/unit/resource/build_essential_spec.rb8
3 files changed, 12 insertions, 1 deletions
diff --git a/kitchen-tests/cookbooks/base/recipes/default.rb b/kitchen-tests/cookbooks/base/recipes/default.rb
index dac989cc81..ea0215ca96 100644
--- a/kitchen-tests/cookbooks/base/recipes/default.rb
+++ b/kitchen-tests/cookbooks/base/recipes/default.rb
@@ -25,7 +25,7 @@ yum_repository "epel" do
only_if { platform_family?("rhel") }
end
-build_essential "install compilation tools"
+build_essential
include_recipe "::packages"
diff --git a/lib/chef/resource/build_essential.rb b/lib/chef/resource/build_essential.rb
index 8d32af9684..155de864f9 100644
--- a/lib/chef/resource/build_essential.rb
+++ b/lib/chef/resource/build_essential.rb
@@ -25,6 +25,9 @@ class Chef
description "Use the build_essential resource to install packages required for compiling C software from source"
introduced "14.0"
+ # this allows us to use build_essential without setting a name
+ property :name, String, default: ""
+
property :compile_time, [TrueClass, FalseClass],
description: "Install build essential packages at compile time.",
default: false
diff --git a/spec/unit/resource/build_essential_spec.rb b/spec/unit/resource/build_essential_spec.rb
index dff94e6bdc..5c25d3e961 100644
--- a/spec/unit/resource/build_essential_spec.rb
+++ b/spec/unit/resource/build_essential_spec.rb
@@ -28,4 +28,12 @@ describe Chef::Resource::BuildEssential do
it "has a default action of install" do
expect(resource.action).to eql([:install])
end
+
+ context "when not settting a resource name" do
+ let(:resource) { Chef::Resource::BuildEssential.new(nil) }
+
+ it "the name defaults to an empty string" do
+ expect(resource.name).to eql("")
+ end
+ end
end