require 'spec_helper'

describe '<%= metadata.name %>' do
  context 'supported operating systems' do
    on_supported_os.each do |os, facts|
      context "on #{os}" do
        let(:facts) do
          facts
        end

        context "<%= metadata.name %> class without any parameters" do
          let(:params) {{ }}

          it { is_expected.to compile.with_all_deps }

          it { is_expected.to contain_class('<%= metadata.name %>::params') }
          it { is_expected.to contain_class('<%= metadata.name %>::install').that_comes_before('<%= metadata.name %>::config') }
          it { is_expected.to contain_class('<%= metadata.name %>::config') }
          it { is_expected.to contain_class('<%= metadata.name %>::service').that_subscribes_to('<%= metadata.name %>::config') }

          it { is_expected.to contain_service('<%= metadata.name %>') }
          it { is_expected.to contain_package('<%= metadata.name %>').with_ensure('present') }
        end
      end
    end
  end
end

require 'spec_helper'

describe '<%= metadata.name %>' do
  context 'supported operating systems' do
    [ "6.1.7600","6.1.7601", "6.2.9200", "6.3.9200", "6.3.9600" ].each do |kernelversion|
      describe "<%= metadata.name %> class without any parameters on Windows" do
        let(:params) {{ }}
        let(:facts) {
          {
            :kernelversion   => kernelversion,
            :operatingsystem => 'windows',
            :osfamily        => 'windows',
          }
        }

        it { is_expected.to compile.with_all_deps }

        it { is_expected.to contain_class('<%= metadata.name %>::params') }
        it { is_expected.to contain_class('<%= metadata.name %>::install').that_comes_before('<%= metadata.name %>::config') }
        it { is_expected.to contain_class('<%= metadata.name %>::config') }
        it { is_expected.to contain_class('<%= metadata.name %>::service').that_subscribes_to('<%= metadata.name %>::config') }

        it { is_expected.to contain_service('<%= metadata.name %>') }
        it { is_expected.to contain_package('<%= metadata.name %>').with_ensure('present') }
      end
    end
  end

  context 'unsupported operating system' do
    describe '<%= metadata.name %> class without any parameters on Solaris/Nexenta' do
      let(:facts) {{
        :osfamily        => 'Solaris',
        :operatingsystem => 'Nexenta',
      }}

      it { expect { is_expected.to contain_package('<%= metadata.name %>') }.to raise_error(Puppet::Error, /Nexenta not supported/) }
    end
  end
end
Change to use Windows Kernel versions for specs
Change to use Windows Kernel versions for specs