require 'spec_helper'

describe 'banner' do
  context 'supported operating systems' do
    on_supported_os.each do |os, facts|
      context "on #{os}" do
        let(:facts) do
          facts
        end

        context "banner class without any parameters" do
          let(:params) {{ }}

          it { is_expected.to compile.with_all_deps }

          it { is_expected.to contain_class('banner::params') }
          it { is_expected.to contain_class('banner::install').that_comes_before('banner::config') }
          it { is_expected.to contain_class('banner::config') }
          it { is_expected.to contain_class('banner::service').that_subscribes_to('banner::config') }

          it { is_expected.to contain_service('banner') }
          it { is_expected.to contain_package('banner').with_ensure('present') }
        end
      end
    end
  end

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

      it { expect { is_expected.to contain_package('banner') }.to raise_error(Puppet::Error, /Nexenta not supported/) }
    end
  end
end
