summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-09-09 20:14:37 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-11-28 11:53:31 -0800
commit1b740269c2d1f24548d13ad2d7e0219c63e42d47 (patch)
tree279f66989aa6e9bce39f50a341f9471d870a7a66
parent79247ca1aa5ade17cdee8545593aa2a3c32bdf68 (diff)
downloadchef-lcg/why-run-safe-ruby-block.tar.gz
add whyrun-safe-ruby-block func testlcg/why-run-safe-ruby-block
tests against the resource and tests the default action
-rw-r--r--spec/functional/resource/whyrun_safe_ruby_block.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/functional/resource/whyrun_safe_ruby_block.rb b/spec/functional/resource/whyrun_safe_ruby_block.rb
new file mode 100644
index 0000000000..4c51fa9263
--- /dev/null
+++ b/spec/functional/resource/whyrun_safe_ruby_block.rb
@@ -0,0 +1,52 @@
+#
+# 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