Sha256: ec1f8fc1d3f956611dda41ec74aa912e740dbf8b7a9dde044af01ae32df6c35b

Contents?: true

Size: 1.44 KB

Versions: 19

Compression:

Stored size: 1.44 KB

Contents

#! /usr/bin/env ruby

require File.dirname(__FILE__) + '/../../../spec_helper'

describe "the generate function" do

  before :each do
    @scope = Puppet::Parser::Scope.new
  end

  it "should exist" do
    Puppet::Parser::Functions.function("generate").should == "function_generate"
  end

  it "should accept a fully-qualified path as a command" do
    command = File::SEPARATOR + "command"
    Puppet::Util.expects(:execute).with([command]).returns("yay")
    lambda { @scope.function_generate([command]) }.should_not raise_error(Puppet::ParseError)
  end

  it "should not accept a relative path as a command" do
    command = "command"
    lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError)
  end

  # Really not sure how to implement this test, just sure it needs
  # to be implemented.
  it "should not accept a command containing illegal characters"

  it "should not accept a command containing '..'" do
    command = File::SEPARATOR + "command#{File::SEPARATOR}..#{File::SEPARATOR}"
    lambda { @scope.function_generate([command]) }.should raise_error(Puppet::ParseError)
  end

  it "should execute the generate script with the correct working directory" do
    command = File::SEPARATOR + "command"
    Dir.expects(:chdir).with(File.dirname(command)).yields
    Puppet::Util.expects(:execute).with([command]).returns("yay")
    lambda { @scope.function_generate([command]) }.should_not raise_error(Puppet::ParseError)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
puppet-2.6.18 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.17 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.16 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.15 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.14 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.13 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.12 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.11 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.10 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.9 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.8 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.7 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.6 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.5 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.4 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.3 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.2 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.1 spec/unit/parser/functions/generate_spec.rb
puppet-2.6.0 spec/unit/parser/functions/generate_spec.rb