diff options
author | sersut <serdar@opscode.com> | 2014-03-30 13:45:00 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2014-03-30 13:45:00 -0700 |
commit | 7a1778fb309423114462d578e01ba0e00108010f (patch) | |
tree | 792e1fbafdca12725edf923cdad22536f3124fc3 /spec/support/shared | |
parent | 0d097217dda26ac5551d1ad24132d9e53a62e0fb (diff) | |
parent | cacf2a53a3b789829dd6b5b2956e07cc1aa42931 (diff) | |
download | chef-8f7830f3a37bfbc37f918c6ae67c664336b737aa.tar.gz |
Merge branch 'master' into 11-stable11.12.0.rc.0
Merging mater branch for RC version.
Diffstat (limited to 'spec/support/shared')
4 files changed, 83 insertions, 3 deletions
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb index afeb4c029c..fc06fb55d0 100644 --- a/spec/support/shared/functional/windows_script.rb +++ b/spec/support/shared/functional/windows_script.rb @@ -23,8 +23,7 @@ shared_context Chef::Resource::WindowsScript do before(:all) do ohai_reader = Ohai::System.new - ohai_reader.require_plugin("os") - ohai_reader.require_plugin("windows::platform") + ohai_reader.all_plugins("platform") new_node = Chef::Node.new new_node.consume_external_attrs(ohai_reader.data,{}) @@ -39,7 +38,7 @@ shared_context Chef::Resource::WindowsScript do end before(:each) do -k File.delete(script_output_path) if File.exists?(script_output_path) + File.delete(script_output_path) if File.exists?(script_output_path) end after(:each) do diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb new file mode 100644 index 0000000000..a0d5e7fa5c --- /dev/null +++ b/spec/support/shared/integration/app_server_support.rb @@ -0,0 +1,42 @@ +# +# Author:: John Keiser (<jkeiser@opscode.com>) +# Author:: Ho-Sheng Hsiao (<hosh@opscode.com>) +# Copyright:: Copyright (c) 2012, 2013 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 'rack' +require 'stringio' + +module AppServerSupport + def start_app_server(app, port) + server = nil + thread = Thread.new do + Rack::Handler::WEBrick.run(app, + :Port => 9018, + :AccessLog => [], + :Logger => WEBrick::Log::new(StringIO.new, 7) + ) do |found_server| + server = found_server + end + end + Timeout::timeout(5) do + until server && server.status == :Running + sleep(0.01) + end + end + [server, thread] + end +end diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 0c4bf990af..abed4c2715 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -23,6 +23,7 @@ require 'chef/config' require 'chef_zero/rspec' require 'json' require 'support/shared/integration/knife_support' +require 'support/shared/integration/app_server_support' require 'spec_helper' module IntegrationSupport diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb index 5f37506df6..1137958420 100644 --- a/spec/support/shared/unit/script_resource.rb +++ b/spec/support/shared/unit/script_resource.rb @@ -48,5 +48,43 @@ shared_examples_for "a script resource" do @resource.flags.should eql("-f") end + describe "when executing guards" do + let(:resource) { @resource } + + before(:each) do + node = Chef::Node.new + + node.automatic[:platform] = "debian" + node.automatic[:platform_version] = "6.0" + + events = Chef::EventDispatch::Dispatcher.new + run_context = Chef::RunContext.new(node, {}, events) + resource.run_context = run_context + resource.code 'echo hi' + end + + it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do + inherited_difference = Chef::Resource::Script.guard_inherited_attributes - + [:cwd, :environment, :group, :path, :user, :umask ] + + inherited_difference.should == [] + end + + it "when guard_interpreter is set to the default value, the guard command string should be evaluated by command execution and not through a resource" do + Chef::Resource::Conditional.any_instance.should_not_receive(:evaluate_block) + Chef::Resource::Conditional.any_instance.should_receive(:evaluate_command).and_return(true) + Chef::GuardInterpreter::ResourceGuardInterpreter.any_instance.should_not_receive(:evaluate_action) + resource.only_if 'echo hi' + resource.should_skip?(:run).should == nil + end + + it "when a valid guard_interpreter resource is specified, a block should be used to evaluate the guard" do + Chef::GuardInterpreter::DefaultGuardInterpreter.any_instance.should_not_receive(:evaluate) + Chef::GuardInterpreter::ResourceGuardInterpreter.any_instance.should_receive(:evaluate_action).and_return(true) + resource.guard_interpreter :script + resource.only_if 'echo hi' + resource.should_skip?(:run).should == nil + end + end end |