summaryrefslogtreecommitdiff
path: root/spec/spec_helper_acceptance.rb
diff options
context:
space:
mode:
authorBryan Jen <bryan.jen@gmail.com>2015-07-30 13:33:44 -0700
committerBryan Jen <bryan.jen@gmail.com>2015-07-30 13:33:44 -0700
commit41a7297cb73e48a9548d7d0137f2ffe4108f248a (patch)
tree255af9c48f0cdc95eabedf20dd4530cb07ea6b43 /spec/spec_helper_acceptance.rb
parent4d889cbcb6f5eb2358eed940f2d40d1f73cc8f51 (diff)
parent956c329a8a2f497b0953e47c307e4cc60b7044e9 (diff)
Merge pull request #495 from puppetlabs/4.7.x
4.7.x
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