Sha256: 1814edfb77df4c7fcaf60b631d5e7a2184961477dae984d340a010fb33b83995

Contents?: true

Size: 1.48 KB

Versions: 18

Compression:

Stored size: 1.48 KB

Contents

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

describe "the generate function" do
  before :all do
    Puppet::Parser::Functions.autoloader.loadall
  end

  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

18 entries across 18 versions & 2 rubygems

Version Path
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.9.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.8.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.8.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
puppet-2.7.11 spec/unit/parser/functions/generate_spec.rb
supply_drop-0.7.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.6.1 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
supply_drop-0.6.0 examples/vendored-puppet/vendor/puppet-2.7.8/spec/unit/parser/functions/generate_spec.rb
puppet-2.7.9 spec/unit/parser/functions/generate_spec.rb
puppet-2.7.8 spec/unit/parser/functions/generate_spec.rb
puppet-2.7.6 spec/unit/parser/functions/generate_spec.rb
puppet-2.7.5 spec/unit/parser/functions/generate_spec.rb
puppet-2.7.4 spec/unit/parser/functions/generate_spec.rb
puppet-2.7.3 spec/unit/parser/functions/generate_spec.rb
puppet-2.7.1 spec/unit/parser/functions/generate_spec.rb