diff options
-rw-r--r-- | lib/chef/resource/conditional.rb | 2 | ||||
-rw-r--r-- | spec/functional/resource/powershell_spec.rb | 26 |
2 files changed, 7 insertions, 21 deletions
diff --git a/lib/chef/resource/conditional.rb b/lib/chef/resource/conditional.rb index ad082c82d1..30abfdec81 100644 --- a/lib/chef/resource/conditional.rb +++ b/lib/chef/resource/conditional.rb @@ -54,7 +54,7 @@ class Chef raise ArgumentError, "only_if/not_if requires either a command or a block" unless block_given? if parent_resource.guard_interpreter != :default msg = "#{parent_resource.name} was given a guard_interpreter of #{parent_resource.guard_interpreter}, " - msg << "but not given a command as a string. guard_interpreter does not support blocks." + msg << "but not given a command as a string. guard_interpreter does not support blocks (because they just contain ruby)." raise ArgumentError, msg end @guard_interpreter = nil diff --git a/spec/functional/resource/powershell_spec.rb b/spec/functional/resource/powershell_spec.rb index 5001e870a9..c30c710959 100644 --- a/spec/functional/resource/powershell_spec.rb +++ b/spec/functional/resource/powershell_spec.rb @@ -162,6 +162,12 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do resource.returns(0) resource.run_action(:run) end + + it "raises an error when given a block and a guard_interpreter" do + resource.guard_interpreter :sh + expect { resource.only_if { true } }.to raise_error(ArgumentError, /guard_interpreter does not support blocks/) + end + end context "when running on a 32-bit version of Windows", :windows32_only do @@ -265,26 +271,6 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do resource.should_skip?(:run).should be_false end - it "evaluates a not_if block as false" do - resource.not_if { false } - resource.should_skip?(:run).should be_false - end - - it "evaluates a not_if block as true" do - resource.not_if { true } - resource.should_skip?(:run).should be_true - end - - it "evaluates an only_if block as false" do - resource.only_if { false } - resource.should_skip?(:run).should be_true - end - - it "evaluates an only_if block as true" do - resource.only_if { true } - resource.should_skip?(:run).should be_false - end - it "evaluates a non-zero powershell exit status for not_if as true" do resource.not_if "exit 37" resource.should_skip?(:run).should be_false |