summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/resource/conditional.rb1
-rw-r--r--spec/unit/resource/conditional_spec.rb7
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/chef/resource/conditional.rb b/lib/chef/resource/conditional.rb
index d188e2ad0b..140078d39a 100644
--- a/lib/chef/resource/conditional.rb
+++ b/lib/chef/resource/conditional.rb
@@ -72,6 +72,7 @@ class Chef
end
end
+ # this is run during convergence via Chef::Resource#run_action -> Chef::Resource#should_skip?
def continue?
# configure late in case guard_interpreter is specified on the resource after the conditional
configure
diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb
index 92ca53118b..8d0fae18f0 100644
--- a/spec/unit/resource/conditional_spec.rb
+++ b/spec/unit/resource/conditional_spec.rb
@@ -36,6 +36,13 @@ describe Chef::Resource::Conditional do
expect { Chef::Resource::Conditional.send(:new, :always, @parent_resource, nil, {})}.to raise_error(ArgumentError, /requires either a command or a block/)
end
+ it "does not evaluate a guard interpreter on initialization of the conditional" do
+ expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:configure)
+ expect(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:new)
+ expect(Chef::GuardInterpreter::ResourceGuardInterpreter).not_to receive(:new)
+ Chef::Resource::Conditional.only_if(@parent_resource, "true")
+ end
+
describe "when created as an `only_if`" do
describe "after running a successful command" do
before do