Sha256: 1359d3344499deb1195ea907c68331ade9cf83ac6efc0dbec518c5a3e3c635e3

Contents?: true

Size: 1.4 KB

Versions: 642

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe "A parser environment setting" do

  let(:confdir) { Puppet[:confdir] }
  let(:environmentpath) { File.expand_path("envdir", confdir) }
  let(:testingdir) { File.join(environmentpath, "testing") }

  before(:each) do
    FileUtils.mkdir_p(testingdir)
  end

  it "selects the given parser when compiling" do
    manifestsdir = File.expand_path("manifests", confdir)
    FileUtils.mkdir_p(manifestsdir)

    File.open(File.join(testingdir, "environment.conf"), "w") do |f|
      f.puts(<<-ENVCONF)
        parser='future'
        manifest =#{manifestsdir}
      ENVCONF
    end

    File.open(File.join(confdir, "puppet.conf"), "w") do |f|
      f.puts(<<-EOF)
          environmentpath=#{environmentpath}
          parser='current'
      EOF
    end

    File.open(File.join(manifestsdir, "site.pp"), "w") do |f|
      f.puts("notice( [1,2,3].map |$x| { $x*10 })")
    end

    expect { a_catalog_compiled_for_environment('testing') }.to_not raise_error
  end

  def a_catalog_compiled_for_environment(envname)
    Puppet.initialize_settings
    expect(Puppet[:environmentpath]).to eq(environmentpath)
    node = Puppet::Node.new('testnode', :environment => 'testing')
    expect(node.environment).to eq(Puppet.lookup(:environments).get('testing'))
    Puppet.override(:current_environment => Puppet.lookup(:environments).get('testing')) do
      Puppet::Parser::Compiler.compile(node)
    end
  end
end

Version data entries

642 entries across 642 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/integration/parser/environment_spec.rb
puppet-8.3.0-x86-mingw32 spec/integration/parser/environment_spec.rb
puppet-8.3.0-x64-mingw32 spec/integration/parser/environment_spec.rb
puppet-8.3.0-universal-darwin spec/integration/parser/environment_spec.rb
puppet-8.4.0 spec/integration/parser/environment_spec.rb
puppet-8.4.0-x86-mingw32 spec/integration/parser/environment_spec.rb
puppet-8.4.0-x64-mingw32 spec/integration/parser/environment_spec.rb
puppet-8.4.0-universal-darwin spec/integration/parser/environment_spec.rb
puppet-7.28.0 spec/integration/parser/environment_spec.rb
puppet-7.28.0-x86-mingw32 spec/integration/parser/environment_spec.rb
puppet-7.28.0-x64-mingw32 spec/integration/parser/environment_spec.rb
puppet-7.28.0-universal-darwin spec/integration/parser/environment_spec.rb
puppet-8.3.1 spec/integration/parser/environment_spec.rb
puppet-8.3.1-x86-mingw32 spec/integration/parser/environment_spec.rb
puppet-8.3.1-x64-mingw32 spec/integration/parser/environment_spec.rb
puppet-8.3.1-universal-darwin spec/integration/parser/environment_spec.rb
puppet-7.27.0 spec/integration/parser/environment_spec.rb
puppet-7.27.0-x86-mingw32 spec/integration/parser/environment_spec.rb
puppet-7.27.0-x64-mingw32 spec/integration/parser/environment_spec.rb
puppet-7.27.0-universal-darwin spec/integration/parser/environment_spec.rb