diff --git a/Gemfile b/Gemfile index 70200dd..3d9d4ad 100644 --- a/Gemfile +++ b/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 diff --git a/spec/classes/tuskar_api_spec.rb b/spec/classes/tuskar_api_spec.rb index 42aac14..122ae55 100644 --- a/spec/classes/tuskar_api_spec.rb +++ b/spec/classes/tuskar_api_spec.rb @@ -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 diff --git a/spec/classes/tuskar_client_spec.rb b/spec/classes/tuskar_client_spec.rb index e803a18..ea2a8c3 100644 --- a/spec/classes/tuskar_client_spec.rb +++ b/spec/classes/tuskar_client_spec.rb @@ -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 diff --git a/spec/classes/tuskar_db_mysql_spec.rb b/spec/classes/tuskar_db_mysql_spec.rb index 1c0792a..c43c4e9 100644 --- a/spec/classes/tuskar_db_mysql_spec.rb +++ b/spec/classes/tuskar_db_mysql_spec.rb @@ -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', diff --git a/spec/classes/tuskar_db_postgresql_spec.rb b/spec/classes/tuskar_db_postgresql_spec.rb index e45cac1..56703bb 100644 --- a/spec/classes/tuskar_db_postgresql_spec.rb +++ b/spec/classes/tuskar_db_postgresql_spec.rb @@ -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' ) } diff --git a/spec/classes/tuskar_init_spec.rb b/spec/classes/tuskar_init_spec.rb index 71fa2f0..46f2d83 100644 --- a/spec/classes/tuskar_init_spec.rb +++ b/spec/classes/tuskar_init_spec.rb @@ -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 diff --git a/spec/classes/tuskar_keystone_auth_spec.rb b/spec/classes/tuskar_keystone_auth_spec.rb index 73ca0dc..bd884c7 100644 --- a/spec/classes/tuskar_keystone_auth_spec.rb +++ b/spec/classes/tuskar_keystone_auth_spec.rb @@ -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 diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index d0c2fe9..dd4ff33 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -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