Révision 64134e4e
Add spec tests it should compile
spec/classes/nftables_spec.rb | ||
---|---|---|
1 |
require 'spec_helper' |
|
2 |
|
|
3 |
describe 'nftables' do |
|
4 |
let(:pre_condition) { 'Exec{path => "/bin"}' } |
|
5 |
|
|
6 |
on_supported_os.each do |os, os_facts| |
|
7 |
context "on #{os}" do |
|
8 |
let(:facts) { os_facts } |
|
9 |
|
|
10 |
it { is_expected.to compile } |
|
11 |
end |
|
12 |
end |
|
13 |
end |
spec/default_facts.yml | ||
---|---|---|
1 |
# Use default_module_facts.yml for module specific facts. |
|
2 |
# |
|
3 |
# Facts specified here will override the values provided by rspec-puppet-facts. |
|
4 |
--- |
|
5 |
ipaddress: "172.16.254.254" |
|
6 |
is_pe: false |
|
7 |
macaddress: "AA:AA:AA:AA:AA:AA" |
spec/spec_helper.rb | ||
---|---|---|
1 |
require 'puppetlabs_spec_helper/module_spec_helper' |
|
2 |
require 'rspec-puppet-facts' |
|
3 |
|
|
4 |
require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) |
|
5 |
|
|
6 |
include RspecPuppetFacts |
|
7 |
|
|
8 |
default_facts = { |
|
9 |
puppetversion: Puppet.version, |
|
10 |
facterversion: Facter.version, |
|
11 |
} |
|
12 |
|
|
13 |
default_fact_files = [ |
|
14 |
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), |
|
15 |
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), |
|
16 |
] |
|
17 |
|
|
18 |
default_fact_files.each do |f| |
|
19 |
next unless File.exist?(f) && File.readable?(f) && File.size?(f) |
|
20 |
|
|
21 |
begin |
|
22 |
default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) |
|
23 |
rescue => e |
|
24 |
RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" |
|
25 |
end |
|
26 |
end |
|
27 |
|
|
28 |
RSpec.configure do |c| |
|
29 |
c.default_facts = default_facts |
|
30 |
c.before :each do |
|
31 |
# set to strictest setting for testing |
|
32 |
# by default Puppet runs at warning level |
|
33 |
Puppet.settings[:strict] = :warning |
|
34 |
end |
|
35 |
c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] |
|
36 |
c.after(:suite) do |
|
37 |
end |
|
38 |
end |
|
39 |
|
|
40 |
def ensure_module_defined(module_name) |
|
41 |
module_name.split('::').reduce(Object) do |last_module, next_module| |
|
42 |
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) |
|
43 |
last_module.const_get(next_module, false) |
|
44 |
end |
|
45 |
end |
|
46 |
|
|
47 |
# 'spec_overrides' from sync.yml will appear below this line |
Formats disponibles : Unified diff