Mercurial > repos > other > Puppet
annotate modules/concat/spec/spec_helper.rb @ 447:1a9de0661666
Add missing package/dir for minimal Ubuntu
Minimal is minimal - no locale, no cron, and some dirs do not
exist
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 08 May 2023 19:24:20 +0100 |
parents | d9352a684e62 |
children |
rev | line source |
---|---|
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
1 RSpec.configure do |c| |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
2 c.mock_with :rspec |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
3 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
4 |
0
956e484adc12
Initial public release of Puppet configs
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 require 'puppetlabs_spec_helper/module_spec_helper' |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
6 require 'rspec-puppet-facts' |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
7 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
8 require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
9 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
10 include RspecPuppetFacts |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
11 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
12 default_facts = { |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
13 puppetversion: Puppet.version, |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
14 facterversion: Facter.version, |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
15 } |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
16 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
17 default_fact_files = [ |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
18 File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
19 File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
20 ] |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
21 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
22 default_fact_files.each do |f| |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
23 next unless File.exist?(f) && File.readable?(f) && File.size?(f) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
24 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
25 begin |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
26 default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
27 rescue => e |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
28 RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
29 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
30 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
31 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
32 # read default_facts and merge them over what is provided by facterdb |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
33 default_facts.each do |fact, value| |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
34 add_custom_fact fact, value |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
35 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
36 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
37 RSpec.configure do |c| |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
38 c.default_facts = default_facts |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
39 c.before :each do |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
40 # set to strictest setting for testing |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
41 # by default Puppet runs at warning level |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
42 Puppet.settings[:strict] = :warning |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
43 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
44 c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
45 c.after(:suite) do |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
46 RSpec::Puppet::Coverage.report!(0) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
47 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
48 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
49 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
50 # Ensures that a module is defined |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
51 # @param module_name Name of the module |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
52 def ensure_module_defined(module_name) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
53 module_name.split('::').reduce(Object) do |last_module, next_module| |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
54 last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
55 last_module.const_get(next_module, false) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
56 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
57 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
58 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
59 # 'spec_overrides' from sync.yml will appear below this line |