summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-05-26 11:50:45 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-05-26 11:50:45 -0700
commit4d1e0dcaded37365e41c567e2b31fdd34e8695ed (patch)
treed1fab322210e83a2e010873cd5c39be2f5456649
parente7d90f9c1cf3cc587d643a25cb74acd209ebcfdb (diff)
parenta8ed6e4f74ada078a1e0b190dad407e9375273fd (diff)
downloadchef-4d1e0dcaded37365e41c567e2b31fdd34e8695ed.tar.gz
Merge pull request #3418 from chef/lcg/add-shell_out-to-resource
add shell_out to resources
-rw-r--r--CHANGELOG.md2
-rw-r--r--lib/chef/resource.rb4
-rw-r--r--spec/unit/resource_spec.rb12
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