voxpupuli / onceover

Your gateway drug to automated infrastructure testing with Puppet
141 stars 45 forks source link

How do I test against different OSes? #276

Open rnelson0 opened 3 years ago

rnelson0 commented 3 years ago

I'm new to using onceover but familiar with using the PDK, where the combination of metadata.json and rspec-puppet-facts lets me loop through all supported OSes:

describe 'profiles::base' do
  on_supported_os.each do |os, os_facts|
    context "on #{os}" do
      let(:facts) { os_facts }
...

In onceover, this generates errors because rspec-puppet-facts is not present:

An error occurred while loading ./spec/classes/profiles/base_spec.rb.
Failure/Error:
    on_supported_os.each do |os, os_facts|
      context "on #{os}" do
        let(:facts) { os_facts }

        it { is_expected.to compile }

        it { is_expected.to contain_class('ca_cert') }
        it { is_expected.to contain_class('sssd') }
        it { is_expected.to contain_class('access') }
        it { is_expected.to contain_class('sudo') }

NameError:
  undefined local variable or method `on_supported_os' for RSpec::ExampleGroups::ProfilesBase:Class
# ./spec/classes/profiles/base_spec.rb:4:in `block in <top (required)>'
# ./spec/classes/profiles/base_spec.rb:3:in `<top (required)>'

What is the recommended way to perform a test against multiple OSes (e.g. RedHat family v7 and v8)?