annotate modules/translate/spec/spec_helper.rb @ 399:2c6065b5be5e

Switch to config-based PHP extensions This makes it compatible with Ubuntu, otherwise it keeps trying to re-install the same module because the "phpX.X" package is a virtual package and the Puppet handling of Ubuntu's "is it installed" system is incapable of saying "yes" when a virtual package is installed.
author IBBoard <dev@ibboard.co.uk>
date Wed, 20 Apr 2022 19:08:14 +0100
parents b0f8b88fea5c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
245
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 RSpec.configure do |c|
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 c.mock_with :rspec
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 require 'puppetlabs_spec_helper/module_spec_helper'
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 require 'rspec-puppet-facts'
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb'))
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 include RspecPuppetFacts
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 default_facts = {
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 puppetversion: Puppet.version,
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 facterversion: Facter.version,
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 }
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 default_fact_files = [
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 ]
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 default_fact_files.each do |f|
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 next unless File.exist?(f) && File.readable?(f) && File.size?(f)
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 begin
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 default_facts.merge!(YAML.safe_load(File.read(f), [], [], true))
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 rescue => e
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}"
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 # read default_facts and merge them over what is provided by facterdb
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 default_facts.each do |fact, value|
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 add_custom_fact fact, value
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 RSpec.configure do |c|
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 c.default_facts = default_facts
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 c.before :each do
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 # set to strictest setting for testing
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 # by default Puppet runs at warning level
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 Puppet.settings[:strict] = :warning
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT']
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 c.after(:suite) do
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 RSpec::Puppet::Coverage.report!(0)
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 # Ensures that a module is defined
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 # @param module_name Name of the module
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 def ensure_module_defined(module_name)
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 module_name.split('::').reduce(Object) do |last_module, next_module|
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 last_module.const_get(next_module, false)
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 end
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58
b0f8b88fea5c Add "translate" module used by MySQL module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 # 'spec_overrides' from sync.yml will appear below this line