Move test assertions closer to apply.

As discussed on another project patches when introducing tests[1], we
would like to keep the tests closer to the where we apply the spec.

This change makes the testing structure consistent to the feedback given
on puppet-bandersnatch discussion.

[1] https://review.openstack.org/#/c/221941/

Change-Id: I7d0d1dc856f03f422fa5331a98f20d5661c462be
Co-Authored-By: Danilo Ramalho <dramalho@thoughtworks.com>
This commit is contained in:
Bruno Tavares 2015-09-24 19:37:09 -03:00
parent a86dbdb500
commit a133b81441
3 changed files with 32 additions and 30 deletions

View File

@ -15,8 +15,38 @@ describe 'puppet-ansible module' do
apply_manifest(default_puppet_module, catch_failures: true)
end
it 'should be idempotent' do
apply_manifest(default_puppet_module, catch_failures: true)
it 'should be idempotent', :if => ['debian', 'ubuntu'].include?(os[:family]) do
apply_manifest(default_puppet_module, catch_changes: true)
end
it 'should be idempotent', :if => ['fedora', 'redhat'].include?(os[:family]) do
pending('this module is not idempotent on CentOS yet')
apply_manifest(default_puppet_module, catch_changes: true)
end
describe 'required python package' do
describe package('ansible') do
it { should be_installed.by('pip') }
end
end
describe 'required files' do
describe file('/etc/ansible/ansible.cfg') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should include 'library=/usr/share/ansible' }
end
describe file('/usr/local/bin/puppet-inventory') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should include "'_meta': {'hostvars': dict()}," }
end
describe file('/etc/logrotate.d/ansible') do
its(:content) { should include '/var/log/ansible.log' }
end
end
end

View File

@ -1,21 +0,0 @@
require 'spec_helper_acceptance'
describe 'required files' do
describe file('/etc/ansible/ansible.cfg') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should include 'library=/usr/share/ansible' }
end
describe file('/usr/local/bin/puppet-inventory') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should include "'_meta': {'hostvars': dict()}," }
end
describe file('/etc/logrotate.d/ansible') do
its(:content) { should include '/var/log/ansible.log' }
end
end

View File

@ -1,7 +0,0 @@
require 'spec_helper_acceptance'
describe 'required python package' do
describe package('ansible') do
it { should be_installed.by('pip') }
end
end