Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 32 additions & 49 deletions spec/classes/apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,26 @@
it {
is_expected.to contain_file('/etc/apache2/sites-enabled').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_file('/etc/apache2/mods-enabled').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_file('/etc/apache2/mods-available').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'false', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'false'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_concat('/etc/apache2/ports.conf').with(
'owner' => 'root', 'group' => 'root',
'mode' => '0644', 'notify' => 'Class[Apache::Service]'
)
'mode' => '0644'
).that_notifies('Class[Apache::Service]')
}
# Assert that load files are placed and symlinked for these mods, but no conf file.
['auth_basic', 'authn_file', 'authz_default', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
Expand Down Expand Up @@ -313,15 +310,14 @@
it {
is_expected.to contain_file('/etc/httpd/conf.d').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_concat('/etc/httpd/conf/ports.conf').with(
'owner' => 'root', 'group' => 'root',
'mode' => '0644', 'notify' => 'Class[Apache::Service]'
)
'mode' => '0644'
).that_notifies('Class[Apache::Service]')
}
describe 'Alternate confd/mod/vhosts directory' do
let :params do
Expand All @@ -336,9 +332,8 @@
it {
is_expected.to contain_file("/etc/httpd/#{dir}").with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
end

Expand Down Expand Up @@ -508,10 +503,8 @@

it {
is_expected.to contain_file('/opt/rh/root/etc/httpd/conf/httpd.conf').with(
'ensure' => 'file',
'notify' => 'Class[Apache::Service]',
'require' => ['Package[httpd]', 'Concat[/etc/httpd/conf/ports.conf]'],
)
'ensure' => 'file',
).that_notifies('Class[Apache::Service]').that_requires(['Package[httpd]', 'Concat[/etc/httpd/conf/ports.conf]'])
}
end

Expand All @@ -523,9 +516,8 @@
it {
is_expected.to contain_file('/etc/httpd/special_conf.d').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
end

Expand Down Expand Up @@ -729,22 +721,20 @@
it {
is_expected.to contain_file('/usr/local/etc/apache24/Vhosts').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_file('/usr/local/etc/apache24/Modules').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_concat('/usr/local/etc/apache24/ports.conf').with(
'owner' => 'root', 'group' => 'wheel',
'mode' => '0644', 'notify' => 'Class[Apache::Service]'
)
'mode' => '0644'
).that_notifies('Class[Apache::Service]')
}
# Assert that load files are placed for these mods, but no conf file.
['auth_basic', 'authn_core', 'authn_file', 'authz_groupfile', 'authz_host', 'authz_user', 'dav', 'env'].each do |modname|
Expand Down Expand Up @@ -798,22 +788,20 @@
it {
is_expected.to contain_file('/etc/apache2/vhosts.d').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_file('/etc/apache2/modules.d').with(
'ensure' => 'directory', 'recurse' => 'true',
'purge' => 'true', 'notify' => 'Class[Apache::Service]',
'require' => 'Package[httpd]'
)
'purge' => 'true'
).that_notifies('Class[Apache::Service]').that_requires('Package[httpd]')
}
it {
is_expected.to contain_concat('/etc/apache2/ports.conf').with(
'owner' => 'root', 'group' => 'wheel',
'mode' => '0644', 'notify' => 'Class[Apache::Service]'
)
'mode' => '0644'
).that_notifies('Class[Apache::Service]')
}
end
context 'on all OSes' do
Expand All @@ -838,10 +826,9 @@

it {
is_expected.to contain_package('httpd').with(
'notify' => 'Class[Apache::Service]',
'ensure' => 'installed',
'name' => 'httpd24-httpd',
)
).that_notifies('Class[Apache::Service]')
}
end
context 'with a custom file_mode parameter' do
Expand Down Expand Up @@ -919,10 +906,6 @@
is_pe: false }
end

it do
expect {
catalogue
}.to raise_error(Puppet::Error, %r{Unsupported osfamily})
end
it { is_expected.to compile.and_raise_error(%r{Unsupported osfamily}) }
end
end
4 changes: 2 additions & 2 deletions spec/classes/mod/authnz_ldap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
let(:params) { { verify_server_cert: 'wrong' } }

it 'raises an error' do
expect { is_expected.to raise_error Puppet::Error }
is_expected.to compile.and_raise_error(%r{parameter 'verify_server_cert' expects a Boolean value, got String})
end
end
end # Debian
Expand Down Expand Up @@ -74,7 +74,7 @@
let(:params) { { verify_server_cert: 'wrong' } }

it 'raises an error' do
expect { is_expected.to raise_error Puppet::Error }
is_expected.to compile.and_raise_error(%r{parameter 'verify_server_cert' expects a Boolean value, got String})
end
end

Expand Down
4 changes: 1 addition & 3 deletions spec/classes/mod/data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
{ apache_version: '2.2' }
end

it 'fails' do
expect { catalogue }.to raise_error(Puppet::Error, %r{mod_data is only available in Apache 2.3 and later})
end
it { is_expected.to compile.and_raise_error(%r{mod_data is only available in Apache 2.3 and later}) }
end
end
end
6 changes: 1 addition & 5 deletions spec/classes/mod/peruser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
}
end

it do
expect {
catalogue
}.to raise_error(Puppet::Error, %r{Unsupported osfamily FreeBSD})
end
it { is_expected.to compile.and_raise_error(%r{Unsupported osfamily FreeBSD}) }
end
context 'on a Gentoo OS' do
let :facts do
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mod/php_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
end

it 'raises an error' do
expect { expect(subject).to contain_apache__mod('php5') }.to raise_error Puppet::Error, %r{mpm_module => 'prefork' or mpm_module => 'itk'}
is_expected.to compile.and_raise_error(%r{mpm_module => 'prefork' or mpm_module => 'itk'})
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/mod/remoteip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
{ apache_version: '2.2' }
end

it { expect { catalogue }.to raise_error(Puppet::Error, %r{mod_remoteip is only available in Apache 2.4}) }
it { is_expected.to compile.and_raise_error(%r{mod_remoteip is only available in Apache 2.4}) }
end
end
end
2 changes: 1 addition & 1 deletion spec/classes/mod/ssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
end

it { expect { catalogue }.to raise_error(Puppet::Error, %r{Unsupported osfamily:}) }
it { is_expected.to compile.and_raise_error(%r{Unsupported osfamily:}) }
end

context 'on a RedHat' do
Expand Down
16 changes: 4 additions & 12 deletions spec/classes/mod/status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
end

it 'expects to succeed array validation' do
expect {
is_expected.to contain_file('status.conf')
}.not_to raise_error
is_expected.to compile
end
end

Expand All @@ -297,9 +295,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
end

it 'expects to fail array validation' do
expect {
is_expected.to contain_file('status.conf')
}.to raise_error(Puppet::Error)
is_expected.to compile.and_raise_error(%r{allow_from})
end
end

Expand All @@ -323,9 +319,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
end

it 'expects to succeed regular expression validation' do
expect {
is_expected.to contain_file('status.conf')
}.not_to raise_error
is_expected.to compile
end
end
end
Expand All @@ -348,9 +342,7 @@ def status_conf_spec_require(requires, extended_status, status_path)
end

it 'expects to fail regular expression validation' do
expect {
is_expected.to contain_file('status.conf')
}.to raise_error(Puppet::Error)
is_expected.to compile.and_raise_error(%r{extended_status})
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/mod/wsgi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
}
end

it { expect { catalogue }.to raise_error Puppet::Error, %r{apache::mod::wsgi - both package_name and mod_path must be specified!} }
it { is_expected.to compile.and_raise_error(%r{apache::mod::wsgi - both package_name and mod_path must be specified!}) }
end
describe 'with mod_path but no package_name' do
let :params do
Expand All @@ -137,7 +137,7 @@
}
end

it { expect { catalogue }.to raise_error Puppet::Error, %r{apache::mod::wsgi - both package_name and mod_path must be specified!} }
it { is_expected.to compile.and_raise_error(%r{apache::mod::wsgi - both package_name and mod_path must be specified!}) }
end
end
context 'on a FreeBSD OS' do
Expand Down