diff options
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | lib/chef/resource.rb | 4 | ||||
-rw-r--r-- | spec/unit/resource_spec.rb | 12 |
3 files changed, 18 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d4a9181a44..12cc902b34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Unreleased * [pr#3397](https://github.com/chef/chef/pull/3397): Validate owner exists in directory resources +* [pr#3418](https://github.com/chef/chef/pull/3418): Add `shell_out` mixin to Chef::Resource class +for use in `not_if`/`only_if` conditionals, etc. ## 12.4.0 diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 2f5c2b7798..757cd442af 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -37,6 +37,7 @@ require 'chef/resource_resolver' require 'chef/mixin/deprecation' require 'chef/mixin/provides' +require 'chef/mixin/shell_out' class Chef class Resource @@ -51,6 +52,9 @@ class Chef include Chef::DSL::RebootPending extend Chef::Mixin::Provides + # This lets user code do things like `not_if { shell_out!("command") }` + include Chef::Mixin::ShellOut + # # The node the current Chef run is using. # diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 0479778f55..3bfd63f5ab 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -35,6 +35,18 @@ describe Chef::Resource do @resource = Chef::Resource.new("funk", @run_context) end + it "should mixin shell_out" do + expect(@resource.respond_to?(:shell_out)).to be true + end + + it "should mixin shell_out!" do + expect(@resource.respond_to?(:shell_out!)).to be true + end + + it "should mixin shell_out_with_systems_locale" do + expect(@resource.respond_to?(:shell_out_with_systems_locale)).to be true + end + describe "when inherited" do it "adds an entry to a list of subclasses" do |