summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-03-15 11:52:10 -0700
committerMatt Robinson <matt@puppetlabs.com>2011-03-15 11:55:59 -0700
commit0d2d6f3f005ee99658ff86b79749f0ba7949beab (patch)
treeee6fcbc2dacc11f321c5877a9bdaaae46359db06 /spec
parentd2e911a1f9dae2cda025bc0f2cbc973cdcff309b (diff)
downloadpuppet-0d2d6f3f005ee99658ff86b79749f0ba7949beab.tar.gz
puppet-0d2d6f3f005ee99658ff86b79749f0ba7949beab.tar.xz
puppet-0d2d6f3f005ee99658ff86b79749f0ba7949beab.zip
(#4884) Add an shell provider for execs
This makes it possible to use shell builtins when the exec is inline bash commands. Paired-with: Max Martin
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/exec/shell_spec.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/unit/provider/exec/shell_spec.rb b/spec/unit/provider/exec/shell_spec.rb
new file mode 100644
index 000000000..44390ff08
--- /dev/null
+++ b/spec/unit/provider/exec/shell_spec.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:exec).provider(:shell)
+
+describe provider_class do
+ before :each do
+ @resource = Puppet::Resource.new(:exec, 'foo')
+ @provider = provider_class.new(@resource)
+ end
+
+ describe "#run" do
+ it "should be able to run builtin shell commands" do
+ output, status = @provider.run("echo foo")
+ status.exitstatus.should == 0
+ output.should == "foo\n"
+ end
+
+ it "should be able to run commands with single quotes in them" do
+ output, status = @provider.run("echo 'foo bar'")
+ status.exitstatus.should == 0
+ output.should == "foo bar\n"
+ end
+
+ it "should be able to run commands with double quotes in them" do
+ output, status = @provider.run("echo 'foo bar'")
+ status.exitstatus.should == 0
+ output.should == "foo bar\n"
+ end
+
+ it "should be able to read values from the environment parameter" do
+ @resource[:environment] = "FOO=bar"
+ output, status = @provider.run("echo $FOO")
+ status.exitstatus.should == 0
+ output.should == "bar\n"
+ end
+ end
+
+ describe "#validatecmd" do
+ it "should always return true because builtins don't need path or to be fully qualified" do
+ @provider.validatecmd('whateverdoesntmatter').should == true
+ end
+ end
+end