summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@getchef.com>2014-09-04 12:20:19 -0700
committerChris Doherty <cdoherty@getchef.com>2014-09-10 16:34:22 -0700
commitc62aae31840d3a9b2bc179273ace9e54690a311d (patch)
treebe6a99cb7821885a8fd2b83402474af066c7111c /lib
parentff9cab9346fdf285e33bb12724b791c1428772b1 (diff)
downloadchef-c62aae31840d3a9b2bc179273ace9e54690a311d.tar.gz
In specs, and possibly elsewhere, Chef::DSL::RebootPending can get mixed in without a #node available. Decline to crash in those situations.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/dsl/reboot_pending.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/chef/dsl/reboot_pending.rb b/lib/chef/dsl/reboot_pending.rb
index 5255cf1166..a81debce99 100644
--- a/lib/chef/dsl/reboot_pending.rb
+++ b/lib/chef/dsl/reboot_pending.rb
@@ -30,7 +30,8 @@ class Chef
# Note that we will silently miss any other platform-specific reboot notices besides Windows+Ubuntu.
def reboot_pending?
- if node.run_context.reboot_requested?
+ # don't break when used as a mixin in contexts without #node (e.g. specs).
+ if self.respond_to?(:node, true) && node.run_context.reboot_requested?
true
elsif platform?("windows")
# PendingFileRenameOperations contains pairs (REG_MULTI_SZ) of filenames that cannot be updated