so here’ a question for the mindshare. Scenario: ...
# puppet
c
so here’ a question for the mindshare. Scenario: roles/profiles method, several component modules, writing tests. As one of the idiomatic recommended processes, it has long been suggested to build a set of profiles that are intended to be applied across an entire fleet into a base_profile in your profiles, and then include that at your classification level. This is simple. When writing tests, if you try to test your base_profile (which only has includes of already-configured profiles), all your tests pass, but rspec “sees” the inccluded resources, and tells you that you have no coverage on those.. For instance: base_profile.pp
Copy code
include profile::foo
include profile::bar
include profile::baz
baz.pp
Copy code
class profile::baz {
  file { '/etc/baz':
    ensure => 'file',
    ...for brevity
  }
}
When you run a test against base_profile like so: base_profile_spec.rb
Copy code
# 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.