CVQuesty
01/15/2026, 2:19 PMinclude profile::foo
include profile::bar
include profile::baz
baz.pp
class profile::baz {
file { '/etc/baz':
ensure => 'file',
...for brevity
}
}
When you run a test against base_profile like so:
base_profile_spec.rb
# frozen_string_literal: true
require 'spec_helper'
describe 'profiles::base_profile' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }
+ let(:pre_condition) {['include profile::foo','include profiles::bar','include profile::baz']}
context 'test the thing' do
it {
<http://is_expected.to|is_expected.to> contain_classs('profile::foo')
}
it {
<http://is_expected.to|is_expected.to> contain_classs('profile::bar')
}
it {
<http://is_expected.to|is_expected.to> contain_classs('profile::baz')
}
end
it { <http://is_expected.to|is_expected.to> compile.with_all_deps }
end
end
end
When you run your tests, the above test will pass, but in the coverage report, it’ll say that profile::baz has no coverage for file { ‘/etc/baz’: }
By putting the resopurce in the base_profile_spec.rb, I can make the complaint go away, but it seemks to me that rspec-puppet should be smart enough to know that the resource that is showing up in memory when the test is running came from an include, and is not actually a part of base_profile_spec.rb (or its corresponding base_profile.pp.
What is the “right”™ way to do this? It seems duplicate work and the wring thing to do to not only put the test of the file resource in the test for profile::baz but also into its encapsulating test for base_profile.
Thanks in advance.