Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Commit

Permalink
Don't use rspec-puppet-facts for bastion_spec.rb
Browse files Browse the repository at this point in the history
rspec-puppet-facts currently doesn't quite work when testing against
Windows servers:
voxpupuli/rspec-puppet-facts#42

Because of that, we now specifically set the os['family'] fact and test
on that. Prior to this, the spec test wasn't running against an example
Windows server at all.
  • Loading branch information
natemccurdy committed Feb 27, 2017
1 parent a61ef37 commit 469c61c
Showing 1 changed file with 45 additions and 39 deletions.
84 changes: 45 additions & 39 deletions spec/classes/bastion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 469c61c

Please sign in to comment.