From 6a012bd225aa24d14cca9ee70010a663cf733682 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Fri, 27 Apr 2018 14:37:35 -0700 Subject: Allow build_essential resource to be used without setting a 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 --- kitchen-tests/cookbooks/base/recipes/default.rb | 2 +- lib/chef/resource/build_essential.rb | 3 +++ spec/unit/resource/build_essential_spec.rb | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) 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 -- cgit v1.2.1