Sha256: b00ec6f78b6cc7a450eeb9c0d33052d5740cac5de7baae90d0d3c35c8118c602

Contents?: true

Size: 1.54 KB

Versions: 28

Compression:

Stored size: 1.54 KB

Contents

module PuppetSpec::Settings

  # It would probably be preferable to refactor defaults.rb such that the real definitions of
  #  these settings were available as a variable, which was then accessible for use during tests.
  #  However, I'm not doing that yet because I don't want to introduce any additional moving parts
  #  to this already very large changeset.
  #  Would be nice to clean this up later.  --cprice 2012-03-20
  TEST_APP_DEFAULT_DEFINITIONS = {
    :name         => { :default => "test", :desc => "name" },
    :logdir       => { :type => :directory, :default => "test", :desc => "logdir" },
    :confdir      => { :type => :directory, :default => "test", :desc => "confdir" },
    :codedir      => { :type => :directory, :default => "test", :desc => "codedir" },
    :vardir       => { :type => :directory, :default => "test", :desc => "vardir" },
    :rundir       => { :type => :directory, :default => "test", :desc => "rundir" },
  }.freeze

  TEST_APP_DEFAULT_VALUES = TEST_APP_DEFAULT_DEFINITIONS.inject({}) do |memo, (key, value)|
    memo[key] = value[:default]
    memo
  end.freeze

  def set_puppet_conf(confdir, settings)
    FileUtils.mkdir_p(confdir)
    write_file(File.join(confdir, "puppet.conf"), settings)
  end

  def set_environment_conf(environmentpath, environment, settings)
    envdir = File.join(environmentpath, environment)
    FileUtils.mkdir_p(envdir)
    write_file(File.join(envdir, 'environment.conf'), settings)
  end

  def write_file(file, contents)
    File.open(file, "w") do |f|
      f.puts(contents)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
puppet-6.29.0 spec/lib/puppet_spec/settings.rb
puppet-6.29.0-x86-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.29.0-x64-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.29.0-universal-darwin spec/lib/puppet_spec/settings.rb
puppet-6.28.0 spec/lib/puppet_spec/settings.rb
puppet-6.28.0-x86-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.28.0-x64-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.28.0-universal-darwin spec/lib/puppet_spec/settings.rb
puppet-6.27.0 spec/lib/puppet_spec/settings.rb
puppet-6.27.0-x86-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.27.0-x64-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.27.0-universal-darwin spec/lib/puppet_spec/settings.rb
puppet-6.26.0 spec/lib/puppet_spec/settings.rb
puppet-6.26.0-x86-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.26.0-x64-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.26.0-universal-darwin spec/lib/puppet_spec/settings.rb
puppet-6.25.1 spec/lib/puppet_spec/settings.rb
puppet-6.25.1-x86-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.25.1-x64-mingw32 spec/lib/puppet_spec/settings.rb
puppet-6.25.1-universal-darwin spec/lib/puppet_spec/settings.rb