summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2014-09-09 14:08:04 -0700
committerPhil Dibowitz <phil@ipom.com>2014-09-09 21:55:10 -0700
commit671abc4b5286181c34e1c4694f90918fbb396c9e (patch)
tree909493c8e189dbae65e06262299b0cb057e11d90 /spec
parent7812f1ce1b0f015ffb73f9da430eca15eb154997 (diff)
downloadchef-671abc4b5286181c34e1c4694f90918fbb396c9e.tar.gz
[11] Fix whyrun_safe_ruby_block regression
`whyrun_safe_ruby_block` broke in the 11 changes.
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/provider/whyrun_safe_ruby_block_spec.rb51
-rw-r--r--spec/unit/provider/whyrun_safe_ruby_block_spec.rb4
2 files changed, 53 insertions, 2 deletions
diff --git a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
new file mode 100644
index 0000000000..150d46d384
--- /dev/null
+++ b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb
@@ -0,0 +1,51 @@
+#
+# Author:: Serdar Sutay (<serdar@opscode.com>)
+# Copyright:: Copyright (c) 2014 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'spec_helper'
+
+describe Chef::Resource::WhyrunSafeRubyBlock do
+ let(:node) { Chef::Node.new }
+
+ let(:run_context) {
+ events = Chef::EventDispatch::Dispatcher.new
+ Chef::RunContext.new(node, {}, events)
+ }
+
+ before do
+ $evil_global_evil_laugh = :wahwah
+ Chef::Config[:why_run] = true
+ end
+
+ after do
+ Chef::Config[:why_run] = false
+ end
+
+ describe "when testing the resource" do
+ let(:new_resource) do
+ r = Chef::Resource::WhyrunSafeRubyBlock.new("reload all", run_context)
+ r.block { $evil_global_evil_laugh = :mwahahaha }
+ r
+ end
+
+ it "updates the evil laugh, even in why-run mode" do
+ new_resource.run_action(new_resource.action)
+ $evil_global_evil_laugh.should == :mwahahaha
+ new_resource.should be_updated
+ end
+ end
+end
diff --git a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
index 5a17aacbd9..d5209248b3 100644
--- a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
+++ b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb
@@ -30,14 +30,14 @@ describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do
end
it "should call the block and flag the resource as updated" do
- @provider.run_action(:create)
+ @provider.run_action(:run)
$evil_global_evil_laugh.should == :mwahahaha
@new_resource.should be_updated
end
it "should call the block and flat the resource as updated - even in whyrun" do
Chef::Config[:why_run] = true
- @provider.run_action(:create)
+ @provider.run_action(:run)
$evil_global_evil_laugh.should == :mwahahaha
@new_resource.should be_updated
Chef::Config[:why_run] = false