Sha256: ae2f5caa8b104a0cf0d0e72f1771192df95152a9af6ac771783e2c5de59ddd5b

Contents?: true

Size: 1.58 KB

Versions: 18

Compression:

Stored size: 1.58 KB

Contents

#!/usr/bin/env rspec
require 'spec_helper'

provider_class = Puppet::Type.type(:exec).provider(:shell)

describe provider_class, :unless => Puppet.features.microsoft_windows? 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("if [ 1 = 1 ]; then echo 'blah'; fi")
      status.exitstatus.should == 0
      output.should == "blah\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 run multiple commands separated by a semicolon" do
      output, status = @provider.run("echo 'foo' ; echo 'bar'")
      status.exitstatus.should == 0
      output.should == "foo\nbar\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

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
puppet-2.7.13 spec/unit/provider/exec/shell_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
puppet-2.7.12 spec/unit/provider/exec/shell_spec.rb
puppet-2.7.11 spec/unit/provider/exec/shell_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/provider/exec/shell_spec.rb
puppet-2.7.9 spec/unit/provider/exec/shell_spec.rb
puppet-2.7.8 spec/unit/provider/exec/shell_spec.rb
puppet-2.7.6 spec/unit/provider/exec/shell_spec.rb
puppet-2.7.5 spec/unit/provider/exec/shell_spec.rb
puppet-2.7.4 spec/unit/provider/exec/shell_spec.rb