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
in order to be prepared for rspec 3.x move.

In details:

  * Use shared_examples "a Puppet::Error" for puppet::error tests
  * Convert 'should' keyword to 'is_expected.to' (prepare rspec 3.x)
  * Fix spec tests for rspec-puppet 2.0.0
  * Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0
  * Clean Gemfile (remove over-specificication of runtime deps of puppetlabs_spec_helper)

Change-Id: I30c00e2cb6f92778a0cf0556c861a2f1ee84bbed
Card: https://trello.com/c/eHXc1Ryd/4-investigate-the-necessary-change-to-be-rspec-puppet-2-0-0-compliant
changes/67/159167/3
Sebastien Badia 8 years ago committed by Gael Chamoulaud
parent 3cc4dfeb9a
commit 82578b3fa3
  1. 4
      Gemfile
  2. 22
      spec/classes/gnocchi_api_spec.rb
  3. 8
      spec/classes/gnocchi_db_mysql_spec.rb
  4. 4
      spec/classes/gnocchi_db_postgresql_spec.rb
  5. 4
      spec/classes/gnocchi_init_spec.rb
  6. 18
      spec/classes/gnocchi_keystone_auth_spec.rb
  7. 10
      spec/classes/gnocchi_storage_ceph_spec.rb
  8. 4
      spec/classes/gnocchi_storage_file_spec.rb
  9. 10
      spec/classes/gnocchi_storage_swift_spec.rb
  10. 12
      spec/shared_examples.rb

@ -2,8 +2,8 @@ source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'rake', '10.1.1'
gem 'rspec', '< 2.99'
gem 'rspec-puppet', '~> 2.0.0', :require => false
gem 'metadata-json-lint'
gem 'puppet-lint-param-docs'
gem 'json'

@ -18,13 +18,13 @@ describe 'gnocchi::api' do
context 'with default parameters' do
it 'installs gnocchi-api package and service' do
should contain_service('gnocchi-api').with(
is_expected.to contain_service('gnocchi-api').with(
:name => platform_params[:api_service_name],
:ensure => 'running',
:hasstatus => true,
:enable => true
)
should contain_package('gnocchi-api').with(
is_expected.to contain_package('gnocchi-api').with(
:name => platform_params[:api_package_name],
:ensure => 'present',
:notify => 'Service[gnocchi-api]'
@ -32,13 +32,13 @@ describe 'gnocchi::api' do
end
it 'configures gnocchi-api with default parameters' do
should contain_gnocchi_config('DEFAULT/verbose').with_value(false)
should contain_gnocchi_config('DEFAULT/debug').with_value(false)
should contain_gnocchi_config('keystone_authtoken/identity_uri').with_value(params[:identity_uri])
should contain_gnocchi_config('keystone_authtoken/admin_tenant_name').with_value(params[:keystone_tenant])
should contain_gnocchi_config('keystone_authtoken/admin_user').with_value(params[:keystone_user])
should contain_gnocchi_config('keystone_authtoken/admin_password').with_value(params[:keystone_password])
should contain_gnocchi_config('keystone_authtoken/admin_password').with_value(params[:keystone_password]).with_secret(true)
is_expected.to contain_gnocchi_config('DEFAULT/verbose').with_value(false)
is_expected.to contain_gnocchi_config('DEFAULT/debug').with_value(false)
is_expected.to contain_gnocchi_config('keystone_authtoken/identity_uri').with_value(params[:identity_uri])
is_expected.to contain_gnocchi_config('keystone_authtoken/admin_tenant_name').with_value(params[:keystone_tenant])
is_expected.to contain_gnocchi_config('keystone_authtoken/admin_user').with_value(params[:keystone_user])
is_expected.to contain_gnocchi_config('keystone_authtoken/admin_password').with_value(params[:keystone_password])
is_expected.to contain_gnocchi_config('keystone_authtoken/admin_password').with_value(params[:keystone_password]).with_secret(true)
end
context 'when using MySQL' do
@ -47,8 +47,8 @@ describe 'gnocchi::api' do
database_connection => 'mysql://gnocchi:pass@10.0.0.1/gnocchi'}"
end
it 'configures gnocchi-api with RabbitMQ' do
should contain_gnocchi_config('database/connection').with_value('mysql://gnocchi:pass@10.0.0.1/gnocchi')
should contain_gnocchi_config('database/connection').with_value('mysql://gnocchi:pass@10.0.0.1/gnocchi').with_secret(true)
is_expected.to contain_gnocchi_config('database/connection').with_value('mysql://gnocchi:pass@10.0.0.1/gnocchi')
is_expected.to contain_gnocchi_config('database/connection').with_value('mysql://gnocchi:pass@10.0.0.1/gnocchi').with_secret(true)
end
end
end

@ -26,11 +26,11 @@ describe 'gnocchi::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('gnocchi').with(
is_expected.to contain_openstacklib__db__mysql('gnocchi').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
@ -47,7 +47,7 @@ describe 'gnocchi::db::mysql' do
end
it {
should contain_openstacklib__db__mysql('gnocchi').with(
is_expected.to contain_openstacklib__db__mysql('gnocchi').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',
@ -65,7 +65,7 @@ describe 'gnocchi::db::mysql' do
end
it {
should contain_openstacklib__db__mysql('gnocchi').with(
is_expected.to contain_openstacklib__db__mysql('gnocchi').with(
:user => params[:user],
:dbname => params[:dbname],
:password_hash => '*58C036CDA51D8E8BBBBF2F9EA5ABF111ADA444F0',

@ -24,7 +24,7 @@ describe 'gnocchi::db::postgresql' do
req_params
end
it { should contain_postgresql__server__db('gnocchi').with(
it { is_expected.to contain_postgresql__server__db('gnocchi').with(
:user => 'gnocchi',
:password => 'md590440288cb225f56d585b88ad270cd37'
)}
@ -47,7 +47,7 @@ describe 'gnocchi::db::postgresql' do
req_params
end
it { should contain_postgresql__server__db('gnocchi').with(
it { is_expected.to contain_postgresql__server__db('gnocchi').with(
:user => 'gnocchi',
:password => 'md590440288cb225f56d585b88ad270cd37'
)}

@ -7,8 +7,8 @@ describe 'gnocchi' do
shared_examples_for 'gnocchi' do
it {
should contain_class('gnocchi::params')
should contain_exec('post-gnocchi_config')
is_expected.to contain_class('gnocchi::params')
is_expected.to contain_exec('post-gnocchi_config')
}
end

@ -15,24 +15,24 @@ describe 'gnocchi::keystone::auth' do
:tenant => 'foobar' }
end
it { should contain_keystone_user('gnocchi').with(
it { is_expected.to contain_keystone_user('gnocchi').with(
:ensure => 'present',
:password => 'gnocchi_password',
:tenant => 'foobar'
) }
it { should contain_keystone_user_role('gnocchi@foobar').with(
it { is_expected.to contain_keystone_user_role('gnocchi@foobar').with(
:ensure => 'present',
:roles => 'admin'
)}
it { should contain_keystone_service('gnocchi').with(
it { is_expected.to contain_keystone_service('gnocchi').with(
:ensure => 'present',
:type => 'gnocchi',
:description => 'OpenStack Datapoint Service'
) }
it { should contain_keystone_endpoint('RegionOne/gnocchi').with(
it { is_expected.to contain_keystone_endpoint('RegionOne/gnocchi').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:8041",
:admin_url => "http://127.0.0.1:8041",
@ -52,7 +52,7 @@ describe 'gnocchi::keystone::auth' do
:admin_address => '10.10.10.12' }
end
it { should contain_keystone_endpoint('RegionOne/gnocchi').with(
it { is_expected.to contain_keystone_endpoint('RegionOne/gnocchi').with(
:ensure => 'present',
:public_url => "https://10.10.10.10:80",
:internal_url => "http://10.10.10.11:82",
@ -66,9 +66,9 @@ describe 'gnocchi::keystone::auth' do
:auth_name => 'gnocchy' }
end
it { should contain_keystone_user('gnocchy') }
it { should contain_keystone_user_role('gnocchy@services') }
it { should contain_keystone_service('gnocchy') }
it { should contain_keystone_endpoint('RegionOne/gnocchy') }
it { is_expected.to contain_keystone_user('gnocchy') }
it { is_expected.to contain_keystone_user_role('gnocchy@services') }
it { is_expected.to contain_keystone_service('gnocchy') }
it { is_expected.to contain_keystone_endpoint('RegionOne/gnocchy') }
end
end

@ -16,11 +16,11 @@ describe 'gnocchi::storage::ceph' do
context 'with default parameters' do
it 'configures gnocchi-api with default parameters' do
should contain_gnocchi_config('storage/driver').with_value('ceph')
should contain_gnocchi_config('storage/ceph_username').with_value('joe')
should contain_gnocchi_config('storage/ceph_keyring').with_value('client.admin')
should contain_gnocchi_config('storage/ceph_pool').with_value('gnocchi')
should contain_gnocchi_config('storage/ceph_conffile').with_value('/etc/ceph/ceph.conf')
is_expected.to contain_gnocchi_config('storage/driver').with_value('ceph')
is_expected.to contain_gnocchi_config('storage/ceph_username').with_value('joe')
is_expected.to contain_gnocchi_config('storage/ceph_keyring').with_value('client.admin')
is_expected.to contain_gnocchi_config('storage/ceph_pool').with_value('gnocchi')
is_expected.to contain_gnocchi_config('storage/ceph_conffile').with_value('/etc/ceph/ceph.conf')
end
end
end

@ -13,8 +13,8 @@ describe 'gnocchi::storage::file' do
context 'with default parameters' do
it 'configures gnocchi-api with default parameters' do
should contain_gnocchi_config('storage/driver').with_value('file')
should contain_gnocchi_config('storage/file_basepath').with_value('/var/lib/gnocchi')
is_expected.to contain_gnocchi_config('storage/driver').with_value('file')
is_expected.to contain_gnocchi_config('storage/file_basepath').with_value('/var/lib/gnocchi')
end
end
end

@ -13,11 +13,11 @@ describe 'gnocchi::storage::swift' do
context 'with default parameters' do
it 'configures gnocchi-api with default parameters' do
should contain_gnocchi_config('storage/driver').with_value('swift')
should contain_gnocchi_config('storage/swift_user').with_value('admin:admin')
should contain_gnocchi_config('storage/swift_key').with_value('admin')
should contain_gnocchi_config('storage/swift_authurl').with_value('http://localhost:8080/auth/v1.0')
should contain_gnocchi_config('storage/swift_auth_version').with_value('1')
is_expected.to contain_gnocchi_config('storage/driver').with_value('swift')
is_expected.to contain_gnocchi_config('storage/swift_user').with_value('admin:admin')
is_expected.to contain_gnocchi_config('storage/swift_key').with_value('admin')
is_expected.to contain_gnocchi_config('storage/swift_authurl').with_value('http://localhost:8080/auth/v1.0')
is_expected.to contain_gnocchi_config('storage/swift_auth_version').with_value('1')
end
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 Gnocchi 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 Gnocchi 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 Gnocchi 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…
Cancel
Save