puppetlabs-stdlib/spec/spec_helper_acceptance.rb

71 lines
1.8 KiB
Ruby
Raw Normal View History

#! /usr/bin/env ruby -S rspec
require 'beaker-rspec'
2015-07-10 02:11:10 +02:00
require 'beaker/puppet_install_helper'
UNSUPPORTED_PLATFORMS = []
2015-07-10 02:11:10 +02:00
run_puppet_install_helper
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
# Readable test descriptions
c.formatter = :documentation
# Configure all nodes in nodeset
c.before :suite do
if ENV['FUTURE_PARSER'] == 'yes'
default[:default_apply_opts] ||= {}
default[:default_apply_opts].merge!({:parser => 'future'})
end
copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib')
end
end
def is_future_parser_enabled?
if default[:type] == 'aio'
return true
elsif default[:default_apply_opts]
return default[:default_apply_opts][:parser] == 'future'
end
return false
end
def get_puppet_version
(on default, puppet('--version')).output.chomp
end
RSpec.shared_context "with faked facts" do
let(:facts_d) do
puppet_version = get_puppet_version
2015-08-11 01:15:54 +02:00
if fact('osfamily') =~ /windows/i
if fact('kernelmajversion').to_f < 6.0
'C:/Documents and Settings/All Users/Application Data/PuppetLabs/facter/facts.d'
else
2015-08-11 01:15:54 +02:00
'C:/ProgramData/PuppetLabs/facter/facts.d'
end
2015-08-12 04:52:43 +02:00
elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true"
2015-08-11 17:29:48 +02:00
'/etc/puppetlabs/facter/facts.d'
else
'/etc/facter/facts.d'
end
end
before :each do
#No need to create on windows, PE creates by default
if fact('osfamily') !~ /windows/i
shell("mkdir -p '#{facts_d}'")
end
end
after :each do
2015-08-12 01:23:06 +02:00
shell("rm -f '#{facts_d}/fqdn.txt'", :acceptable_exit_codes => [0,1])
end
def fake_fact(name, value)
shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'")
end
end