spec: updates for rspec-puppet 2.x and rspec 3.x
This patch aim to update our specs test in order to work with the rspec-puppet release 2.0.0, in the mean time, we update rspec syntax order to be prepared for rspec 3.x move. In details: * Convert 'should' keyword to 'is_expected.to' (prepare rspec 3.x) * Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0 Change-Id: Ic9ac859be612f2afc5486340e5aa8eaf83473ab4
This commit is contained in:
parent
5639796a41
commit
7c18a413d3
3
Gemfile
3
Gemfile
@ -2,10 +2,11 @@ source 'https://rubygems.org'
|
||||
|
||||
group :development, :test do
|
||||
gem 'puppetlabs_spec_helper', :require => false
|
||||
gem 'rspec-puppet', '~> 2.0.0', :require => false
|
||||
|
||||
gem 'metadata-json-lint'
|
||||
gem 'puppet-lint-param-docs'
|
||||
|
||||
gem 'rspec-puppet', '~> 1.0.1'
|
||||
gem 'json'
|
||||
gem 'webmock'
|
||||
end
|
||||
|
@ -18,13 +18,13 @@ describe 'tuskar::api' do
|
||||
context 'with default parameters' do
|
||||
|
||||
it 'installs tuskar-api package and service' do
|
||||
should contain_service('tuskar-api').with(
|
||||
is_expected.to contain_service('tuskar-api').with(
|
||||
:name => platform_params[:api_service_name],
|
||||
:ensure => 'running',
|
||||
:hasstatus => true,
|
||||
:enable => true
|
||||
)
|
||||
should contain_package('tuskar-api').with(
|
||||
is_expected.to contain_package('tuskar-api').with(
|
||||
:name => platform_params[:api_package_name],
|
||||
:ensure => 'present',
|
||||
:notify => 'Service[tuskar-api]'
|
||||
@ -32,15 +32,15 @@ describe 'tuskar::api' do
|
||||
end
|
||||
|
||||
it 'configures tuskar-api with default parameters' do
|
||||
should contain_tuskar_config('DEFAULT/verbose').with_value(false)
|
||||
should contain_tuskar_config('DEFAULT/debug').with_value(false)
|
||||
should contain_tuskar_config('DEFAULT/tuskar_api_bind_ip').with_value('0.0.0.0')
|
||||
should contain_tuskar_config('DEFAULT/tuskar_api_port').with_value('8585')
|
||||
should contain_tuskar_config('keystone_authtoken/identity_uri').with_value(params[:identity_uri])
|
||||
should contain_tuskar_config('keystone_authtoken/admin_tenant_name').with_value(params[:keystone_tenant])
|
||||
should contain_tuskar_config('keystone_authtoken/admin_user').with_value(params[:keystone_user])
|
||||
should contain_tuskar_config('keystone_authtoken/admin_password').with_value(params[:keystone_password])
|
||||
should contain_tuskar_config('keystone_authtoken/admin_password').with_value(params[:keystone_password]).with_secret(true)
|
||||
is_expected.to contain_tuskar_config('DEFAULT/verbose').with_value(false)
|
||||
is_expected.to contain_tuskar_config('DEFAULT/debug').with_value(false)
|
||||
is_expected.to contain_tuskar_config('DEFAULT/tuskar_api_bind_ip').with_value('0.0.0.0')
|
||||
is_expected.to contain_tuskar_config('DEFAULT/tuskar_api_port').with_value('8585')
|
||||
is_expected.to contain_tuskar_config('keystone_authtoken/identity_uri').with_value(params[:identity_uri])
|
||||
is_expected.to contain_tuskar_config('keystone_authtoken/admin_tenant_name').with_value(params[:keystone_tenant])
|
||||
is_expected.to contain_tuskar_config('keystone_authtoken/admin_user').with_value(params[:keystone_user])
|
||||
is_expected.to contain_tuskar_config('keystone_authtoken/admin_password').with_value(params[:keystone_password])
|
||||
is_expected.to contain_tuskar_config('keystone_authtoken/admin_password').with_value(params[:keystone_password]).with_secret(true)
|
||||
end
|
||||
|
||||
context 'when using MySQL' do
|
||||
@ -49,8 +49,8 @@ describe 'tuskar::api' do
|
||||
database_connection => 'mysql://tuskar:pass@10.0.0.1/tuskar'}"
|
||||
end
|
||||
it 'configures tuskar-api with RabbitMQ' do
|
||||
should contain_tuskar_config('database/sql_connection').with_value('mysql://tuskar:pass@10.0.0.1/tuskar')
|
||||
should contain_tuskar_config('database/sql_connection').with_value('mysql://tuskar:pass@10.0.0.1/tuskar').with_secret(true)
|
||||
is_expected.to contain_tuskar_config('database/sql_connection').with_value('mysql://tuskar:pass@10.0.0.1/tuskar')
|
||||
is_expected.to contain_tuskar_config('database/sql_connection').with_value('mysql://tuskar:pass@10.0.0.1/tuskar').with_secret(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -8,14 +8,14 @@ describe 'tuskar::client' do
|
||||
shared_examples_for 'tuskar client' do
|
||||
|
||||
context 'with default parameters' do
|
||||
it { should contain_package('python-tuskarclient').with_ensure('present') }
|
||||
it { is_expected.to contain_package('python-tuskarclient').with_ensure('present') }
|
||||
end
|
||||
|
||||
context 'with package_ensure parameter provided' do
|
||||
let :params do
|
||||
{ :package_ensure => false }
|
||||
end
|
||||
it { should contain_package('python-tuskarclient').with_ensure('false') }
|
||||
it { is_expected.to contain_package('python-tuskarclient').with_ensure('false') }
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -26,11 +26,11 @@ describe 'tuskar::db::mysql' do
|
||||
|
||||
context 'when omiting the required parameter password' do
|
||||
before { params.delete(:password) }
|
||||
it { expect { should raise_error(Puppet::Error) } }
|
||||
it { expect { is_expected.to raise_error(Puppet::Error) } }
|
||||
end
|
||||
|
||||
it 'creates a mysql database' do
|
||||
should contain_openstacklib__db__mysql('tuskar').with(
|
||||
is_expected.to contain_openstacklib__db__mysql('tuskar').with(
|
||||
:user => params[:user],
|
||||
:dbname => params[:dbname],
|
||||
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
|
||||
@ -47,7 +47,7 @@ describe 'tuskar::db::mysql' do
|
||||
end
|
||||
|
||||
it {
|
||||
should contain_openstacklib__db__mysql('tuskar').with(
|
||||
is_expected.to contain_openstacklib__db__mysql('tuskar').with(
|
||||
:user => params[:user],
|
||||
:dbname => params[:dbname],
|
||||
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
|
||||
@ -65,7 +65,7 @@ describe 'tuskar::db::mysql' do
|
||||
end
|
||||
|
||||
it {
|
||||
should contain_openstacklib__db__mysql('tuskar').with(
|
||||
is_expected.to contain_openstacklib__db__mysql('tuskar').with(
|
||||
:user => params[:user],
|
||||
:dbname => params[:dbname],
|
||||
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
|
||||
|
@ -17,7 +17,7 @@ describe 'tuskar::db::postgresql' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
it { should contain_postgresql__db('tuskar').with(
|
||||
it { is_expected.to contain_postgresql__db('tuskar').with(
|
||||
:user => 'tuskar',
|
||||
:password => 'pw'
|
||||
) }
|
||||
|
@ -7,8 +7,8 @@ describe 'tuskar' do
|
||||
|
||||
shared_examples_for 'tuskar' do
|
||||
it {
|
||||
should contain_class('tuskar::params')
|
||||
should contain_exec('post-tuskar_config')
|
||||
is_expected.to contain_class('tuskar::params')
|
||||
is_expected.to contain_exec('post-tuskar_config')
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -15,24 +15,24 @@ describe 'tuskar::keystone::auth' do
|
||||
:tenant => 'foobar' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('tuskar').with(
|
||||
it { is_expected.to contain_keystone_user('tuskar').with(
|
||||
:ensure => 'present',
|
||||
:password => 'tuskar_password',
|
||||
:tenant => 'foobar'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_user_role('tuskar@foobar').with(
|
||||
it { is_expected.to contain_keystone_user_role('tuskar@foobar').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('tuskar').with(
|
||||
it { is_expected.to contain_keystone_service('tuskar').with(
|
||||
:ensure => 'present',
|
||||
:type => 'management',
|
||||
:description => 'Tuskar Management Service'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/tuskar').with(
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/tuskar').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "http://127.0.0.1:8585",
|
||||
:admin_url => "http://127.0.0.1:8585",
|
||||
@ -62,7 +62,7 @@ describe 'tuskar::keystone::auth' do
|
||||
:admin_address => '10.10.10.12' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_endpoint('RegionOne/tuskar').with(
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/tuskar').with(
|
||||
:ensure => 'present',
|
||||
:public_url => "https://10.10.10.10:80",
|
||||
:internal_url => "http://10.10.10.11:81",
|
||||
@ -76,9 +76,9 @@ describe 'tuskar::keystone::auth' do
|
||||
:auth_name => 'tuskary' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('tuskary') }
|
||||
it { should contain_keystone_user_role('tuskary@services') }
|
||||
it { should contain_keystone_service('tuskary') }
|
||||
it { should contain_keystone_endpoint('RegionOne/tuskary') }
|
||||
it { is_expected.to contain_keystone_user('tuskary') }
|
||||
it { is_expected.to contain_keystone_user_role('tuskary@services') }
|
||||
it { is_expected.to contain_keystone_service('tuskary') }
|
||||
it { is_expected.to contain_keystone_endpoint('RegionOne/tuskary') }
|
||||
end
|
||||
end
|
||||
|
@ -1,6 +1,6 @@
|
||||
shared_examples_for "a Puppet::Error" do |description|
|
||||
it "with message matching #{description.inspect}" do
|
||||
expect { should have_class_count(1) }.to raise_error(Puppet::Error, description)
|
||||
expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description)
|
||||
end
|
||||
end
|
||||
|
||||
@ -8,12 +8,12 @@ shared_examples 'generic Tuskar service' do |service|
|
||||
|
||||
context 'with default parameters' do
|
||||
it 'installs package and service' do
|
||||
should contain_package(service[:name]).with({
|
||||
is_expected.to contain_package(service[:name]).with({
|
||||
:name => service[:package_name],
|
||||
:ensure => 'present',
|
||||
:notify => "Service[#{service[:name]}]"
|
||||
})
|
||||
should contain_service(service[:name]).with({
|
||||
is_expected.to contain_service(service[:name]).with({
|
||||
:name => service[:service_name],
|
||||
:ensure => 'stopped',
|
||||
:hasstatus => true,
|
||||
@ -29,12 +29,12 @@ shared_examples 'generic Tuskar service' do |service|
|
||||
end
|
||||
|
||||
it 'installs package and service' do
|
||||
should contain_package(service[:name]).with({
|
||||
is_expected.to contain_package(service[:name]).with({
|
||||
:name => service[:package_name],
|
||||
:ensure => '2014.1-1',
|
||||
:notify => "Service[#{service[:name]}]"
|
||||
})
|
||||
should contain_service(service[:name]).with({
|
||||
is_expected.to contain_service(service[:name]).with({
|
||||
:name => service[:service_name],
|
||||
:ensure => 'running',
|
||||
:hasstatus => true,
|
||||
@ -50,7 +50,7 @@ shared_examples 'generic Tuskar service' do |service|
|
||||
end
|
||||
|
||||
it 'does not control service state' do
|
||||
should contain_service(service[:name]).without_ensure
|
||||
is_expected.to contain_service(service[:name]).without_ensure
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user