1 if ENV['COVERAGE'] == 'yes'
3 require 'simplecov-console'
6 SimpleCov.formatters = [
7 SimpleCov::Formatter::HTMLFormatter,
8 SimpleCov::Formatter::Console,
9 SimpleCov::Formatter::Codecov,
12 track_files 'lib/**/*.rb'
16 # do not track vendored files
20 # do not track gitignored files
21 # this adds about 4 seconds to the coverage check
22 # this could definitely be optimized
24 # system returns true if exit status is 0, which with git-check-ignore means file is ignored
25 system("git check-ignore --quiet #{f.filename}")
30 shared_examples 'Puppet::Parameter::Boolean' do |parameter|
31 [true, :true, 'true', :yes, 'yes'].each do |value|
32 it "accepts #{value} (#{value.class}) as a value" do
33 resource[parameter] = value
34 expect(resource[parameter]).to eq(true)
38 [false, :false, 'false', :no, 'no'].each do |value|
39 it "accepts #{value} (#{value.class}) as a value" do
40 resource[parameter] = value
41 expect(resource[parameter]).to eq(false)
45 it 'does not accept "foo" as a value' do
46 expect { resource[parameter] = 'foo' }.to raise_error(%r{Invalid value "foo"})
50 shared_examples 'a parameter that accepts only string values' do |parameter|
51 it 'accepts a string value' do
52 resource[parameter] = 'foo'
53 expect(resource[parameter]).to eq('foo')
56 it 'does not accept an array value' do
57 expect { resource[parameter] = ['foo', 'bar'] }.to raise_error(%r{must be a String})
60 it 'does not accept a hash value' do
61 expect { resource[parameter] = { foo: 'bar' } }.to raise_error(%r{must be a String})
64 it 'does not accept an integer value' do
65 expect { resource[parameter] = 9001 }.to raise_error(%r{must be a String})
68 it 'does not accept a boolean true value' do
69 expect { resource[parameter] = true }.to raise_error(%r{must be a String})
72 it 'does not accept a boolean false value' do
73 expect { resource[parameter] = false }.to raise_error(%r{must be a String})