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.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb
index 7b09a38..03ff993 100755
--- a/spec/spec_helper_acceptance.rb
+++ b/spec/spec_helper_acceptance.rb
@@ -32,3 +32,37 @@ 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 Puppet::Util::Package.versioncmp(puppet_version, '4.0.0') < 0 && fact('is_pe', '--puppet') == "true"
+ 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
+ else
+ '/etc/puppetlabs/facter/facts.d'
+ end
+ 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'")
+ end
+
+ def fake_fact(name, value)
+ shell("echo #{name}=#{value} > '#{facts_d}/#{name}.txt'")
+ end
+end