diff --git a/spec/classes/bastion_spec.rb b/spec/classes/bastion_spec.rb index 3e63635..889b89c 100644 --- a/spec/classes/bastion_spec.rb +++ b/spec/classes/bastion_spec.rb @@ -5,45 +5,51 @@ Puppet.settings[:server] = 'puppet.master.local' end - on_supported_os.each do |os, facts| - context "on #{os}" do - let(:facts) do - facts - end - - case facts[:os][:family] - when 'windows' - - let(:params) do - { - # Need to set the location to a POSIX path for the spec test to work: - # https://github.com/rodjek/rspec-puppet/issues/192 - scripts_install_location: '/tmp', - master_port: 9999, - script_name: 'meow.ps1' - } - end - - it { is_expected.to compile.with_all_deps } - - it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_ensure('file') } - it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_path('/tmp/Invoke-PuppetAgentInstall.ps1') } - it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_content(%r{puppet\.master\.local}) } - it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_content(%r{9999}) } - it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_content(%r{meow\.ps1}) } - - else - - let(:params) do - { - # Need to set the location to a POSIX path for the spec test to work: - # https://github.com/rodjek/rspec-puppet/issues/192 - scripts_install_location: '/tmp' - } - end - - it { is_expected.to raise_error(%r{class must only be applied to Windows agents}) } - end + context 'on a Windows bastion' do + let(:facts) do + { + os: { family: 'windows' } + } end + + let(:params) do + { + # Need to set the location to a POSIX path for the spec test to work: + # https://github.com/rodjek/rspec-puppet/issues/192 + scripts_install_location: '/tmp', + master_port: 9999, + script_name: 'meow.ps1' + } + end + + it { is_expected.to compile.with_all_deps } + + it do + is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with( + 'ensure' => 'file', + 'path' => '/tmp/Invoke-PuppetAgentInstall.ps1' + ) + end + + it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_content(%r{puppet\.master\.local}) } + it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_content(%r{9999}) } + it { is_expected.to contain_file('Windows Puppet Agent Bulk Installer').with_content(%r{meow\.ps1}) } + end + + context 'on a non-windows server' do + let(:facts) do + { + os: { family: 'RedHat' } + } + end + let(:params) do + { + # Need to set the location to a POSIX path for the spec test to work: + # https://github.com/rodjek/rspec-puppet/issues/192 + scripts_install_location: '/tmp' + } + end + + it { is_expected.to raise_error(%r{class must only be applied to Windows agents}) } end end