summaryrefslogtreecommitdiff
path: root/spec/unit/provider/execute_spec.rb
diff options
context:
space:
mode:
authorPavel Valodzka <pavel@valodzka.name>2013-02-05 05:03:09 +0700
committerBryan McLellan <btm@opscode.com>2013-04-12 11:35:38 -0700
commit7bc64aacd0acbcde66077515d54c101ca8e61310 (patch)
tree7490bc0b2378beb818309d7a03f8c3f770d0ce80 /spec/unit/provider/execute_spec.rb
parent084cec650a242c261c7987a45baa475cd67b8edf (diff)
downloadchef-7bc64aacd0acbcde66077515d54c101ca8e61310.tar.gz
execute check existense of sentiel file with respect to cwd
Diffstat (limited to 'spec/unit/provider/execute_spec.rb')
-rw-r--r--spec/unit/provider/execute_spec.rb28
1 files changed, 27 insertions, 1 deletions
diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb
index a944793a89..bf913cca12 100644
--- a/spec/unit/provider/execute_spec.rb
+++ b/spec/unit/provider/execute_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Provider::Execute do
@new_resource = Chef::Resource::Execute.new("foo_resource", @run_context)
@new_resource.timeout 3600
@new_resource.returns 0
- @new_resource.creates "foo_resource"
+ @new_resource.creates "/foo_resource"
@provider = Chef::Provider::Execute.new(@new_resource, @run_context)
@current_resource = Chef::Resource::Ifconfig.new("foo_resource", @run_context)
@provider.current_resource = @current_resource
@@ -46,6 +46,7 @@ describe Chef::Provider::Execute do
opts[:log_tag] = @new_resource.to_s
opts[:live_stream] = STDOUT
@provider.should_receive(:shell_out!).with(@new_resource.command, opts)
+ Chef::Log.should_not_receive(:warn)
@provider.run_action(:run)
@new_resource.should be_updated
@@ -55,6 +56,31 @@ describe Chef::Provider::Execute do
@provider.stub!(:load_current_resource)
File.should_receive(:exists?).with(@new_resource.creates).and_return(true)
@provider.should_not_receive(:shell_out!)
+ Chef::Log.should_not_receive(:warn)
+
+ @provider.run_action(:run)
+ @new_resource.should_not be_updated
+ end
+
+ it "should respect cwd options for 'creates'" do
+ @new_resource.cwd "/tmp"
+ @new_resource.creates "foo_resource"
+ @provider.stub!(:load_current_resource)
+ File.should_receive(:exists?).with(@new_resource.creates).and_return(false)
+ File.should_receive(:exists?).with(File.join("/tmp", @new_resource.creates)).and_return(true)
+ Chef::Log.should_not_receive(:warn)
+ @provider.should_not_receive(:shell_out!)
+
+ @provider.run_action(:run)
+ @new_resource.should_not be_updated
+ end
+
+ it "should warn if user specified relative path without cwd" do
+ @new_resource.creates "foo_resource"
+ @provider.stub!(:load_current_resource)
+ Chef::Log.should_receive(:warn).with(/relative path/)
+ File.should_receive(:exists?).with(@new_resource.creates).and_return(true)
+ @provider.should_not_receive(:shell_out!)
@provider.run_action(:run)
@new_resource.should_not be_updated