This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
spec_helper.rb
74 lines (58 loc) · 2.18 KB
/
spec_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require 'rspec-puppet'
require 'puppet'
require 'puppetlabs_spec_helper/module_spec_helper'
HERE = File.expand_path(File.dirname(__FILE__))
RSpec.configure do |c|
c.mock_framework = :rspec
c.hiera_config = 'spec/fixtures/hiera/hiera.yaml'
c.module_path = [
File.join(HERE, 'modules'),
File.join(HERE, 'vendor', 'modules')
].join(':')
c.order = 'rand'
c.strict_variables = ENV['PUPPET_RSPEC_STRICT_VARIABLES'] == '1'
if ENV['PUPPET_RSPEC_FUTURE_PARSER'] == '1'
c.parser = 'future'
end
c.profile_examples = ENV['PUPPET_RSPEC_PROFILE_EXAMPLES'] == '1'
possible_releases = {
'trusty' => '14.04',
}
dist_preferred = ENV.fetch('DIST_PREFERRED', 'trusty')
unless possible_releases.has_key?(dist_preferred)
raise "DIST_PREFERRED must be one of " + possible_releases.keys.join(', ')
end
# Sensible defaults to satisfy modules that perform OS checking. These
# keys can be overridden by more specific `let(:facts)` in spec contexts.
c.default_facts = {
:osfamily => 'Debian',
:operatingsystem => 'Ubuntu',
:operatingsystemrelease => possible_releases[dist_preferred],
:lsbdistid => 'Debian',
:lsbdistcodename => dist_preferred,
:lsbmajdistrelease => 14,
:architecture => 'amd64',
:fqdn_metrics => 'fakehost-1_management',
:puppetversion => '3.8.6',
:kernel => 'Linux',
:kernelrelease => '3.16.0-77-generic',
:ipaddress_eth0 => '127.0.0.1',
:aws_migration => false,
}
c.confdir = '/etc/puppet'
c.after(:suite) do
if ENV.fetch('FULL_COVERAGE_REPORT', false)
RSpec::Puppet::Coverage.report!
else
# The report! method is hard-coded to use `puts` so the only way to
# modify its behaviour is to capture STDOUT and re-write it here.
captured_stdout = StringIO.new
$stdout = captured_stdout
RSpec::Puppet::Coverage.report!
lines = $stdout.string.split("\n")
# Only match the three lines we care about
summary = lines.select{ |l| /^(?:Total|Touched|Resource)/ =~ l }.join("\n")
STDOUT.puts "\n\n#{summary}"
end
end
end