summaryrefslogtreecommitdiff
path: root/spec/spec_helper_acceptance.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/spec_helper_acceptance.rb')
-rwxr-xr-xspec/spec_helper_acceptance.rb54
1 files changed, 34 insertions, 20 deletions
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 39d2d52..f784112 100755
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -1,28 +1,10 @@
#! /usr/bin/env ruby -S rspec
require 'beaker-rspec'
+require 'beaker/puppet_install_helper'
UNSUPPORTED_PLATFORMS = []
-unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no'
- foss_opts = {
- :default_action => 'gem_install',
- :version => (ENV['PUPPET_VERSION'] || '3.8.1'),
- }
-
- if default.is_pe?; then install_pe; else install_puppet( foss_opts ); end
-
- hosts.each do |host|
- if host['platform'] !~ /windows/i
- if host.is_pe?
- on host, 'mkdir -p /etc/puppetlabs/facter/facts.d'
- else
- on host, "/bin/touch #{host['puppetpath']}/hiera.yaml"
- on host, "mkdir -p #{host['distmoduledir']}"
- on host, 'mkdir -p /etc/facter/facts.d'
- end
- end
- end
-end
+run_puppet_install_helper
RSpec.configure do |c|
# Project root
@@ -50,3 +32,35 @@ def is_future_parser_enabled?
end
return false
end
+
+RSpec.shared_context "with faked facts" do
+ let(:facts_d) do
+ puppet_version = (on default, puppet('--version')).output.chomp
+ 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
+ 'C:/ProgramData/PuppetLabs/facter/facts.d'
+ end
+ elsif Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 and fact('is_pe', '--puppet') == "true"
+ '/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
+ 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