diff --git a/Gemfile b/Gemfile index 748d075c..65c29c4e 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,7 @@ source 'https://rubygems.org' group :development, :test do gem 'puppetlabs_spec_helper', :require => false + gem 'rspec-puppet', '~> 2.0.0', :require => false gem 'puppet-lint', '~> 1.1.0' gem 'metadata-json-lint' @@ -16,9 +17,6 @@ group :development, :test do gem 'puppet-lint-variable_contains_upcase' gem 'puppet-lint-numericvariable' - gem 'rspec-puppet', '~> 1.0.1' - gem 'rake', '10.1.1' - gem 'rspec', '< 2.99' gem 'json' gem 'webmock' end diff --git a/spec/classes/horizon_init_spec.rb b/spec/classes/horizon_init_spec.rb index 2fcbc48e..4e18df81 100644 --- a/spec/classes/horizon_init_spec.rb +++ b/spec/classes/horizon_init_spec.rb @@ -25,20 +25,20 @@ describe 'horizon' do context 'with default parameters' do it { - should contain_package('python-lesscpy').with_ensure('present') - should contain_package('horizon').with( + is_expected.to contain_package('python-lesscpy').with_ensure('present') + is_expected.to contain_package('horizon').with( :ensure => 'present', :tag => 'openstack' ) } - it { should contain_exec('refresh_horizon_django_cache').with({ + it { is_expected.to contain_exec('refresh_horizon_django_cache').with({ :command => '/usr/share/openstack-dashboard/manage.py compress', :refreshonly => true, })} - it { should contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') } + it { is_expected.to contain_concat(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') } it 'configures apache' do - should contain_class('horizon::wsgi::apache').with({ + is_expected.to contain_class('horizon::wsgi::apache').with({ :servername => 'some.host.tld', :listen_ssl => false, :servername => 'some.host.tld', @@ -47,7 +47,7 @@ describe 'horizon' do end it 'generates local_settings.py' do - verify_concat_fragment_contents(subject, 'local_settings.py', [ + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ 'DEBUG = False', "ALLOWED_HOSTS = ['*', ]", "SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0'", @@ -71,13 +71,13 @@ describe 'horizon' do ]) # From internals of verify_contents, get the contents to check for absence of a line - content = subject.resource('concat::fragment', 'local_settings.py').send(:parameters)[:content] + content = catalogue.resource('concat::fragment', 'local_settings.py').send(:parameters)[:content] # With default options, should _not_ have a line to configure SESSION_ENGINE - content.should_not match(/^SESSION_ENGINE/) + expect(content).not_to match(/^SESSION_ENGINE/) end - it { should_not contain_file(params[:file_upload_temp_dir]) } + it { is_expected.not_to contain_file(params[:file_upload_temp_dir]) } end context 'with overridden parameters' do @@ -102,7 +102,7 @@ describe 'horizon' do end it 'generates local_settings.py' do - verify_concat_fragment_contents(subject, 'local_settings.py', [ + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ 'DEBUG = True', "ALLOWED_HOSTS = ['*', ]", 'CSRF_COOKIE_SECURE = True', @@ -129,9 +129,9 @@ describe 'horizon' do ]) end - it { should_not contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') } + it { is_expected.not_to contain_file(platforms_params[:config_file]).that_notifies('Exec[refresh_horizon_django_cache]') } - it { should contain_file(params[:file_upload_temp_dir]) } + it { is_expected.to contain_file(params[:file_upload_temp_dir]) } end context 'with overridden parameters and cache_server_ip array' do @@ -142,12 +142,12 @@ describe 'horizon' do end it 'generates local_settings.py' do - verify_concat_fragment_contents(subject, 'local_settings.py', [ + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ " 'LOCATION': [ '10.0.0.1:11211','10.0.0.2:11211', ],", ]) end - it { should contain_exec('refresh_horizon_django_cache') } + it { is_expected.to contain_exec('refresh_horizon_django_cache') } end context 'with vhost_extra_params' do @@ -158,7 +158,7 @@ describe 'horizon' do end it 'configures apache' do - should contain_class('horizon::wsgi::apache').with({ + is_expected.to contain_class('horizon::wsgi::apache').with({ :extra_params => { 'add_listen' => false }, }) end @@ -177,7 +177,7 @@ describe 'horizon' do end it 'configures apache' do - should contain_class('horizon::wsgi::apache').with({ + is_expected.to contain_class('horizon::wsgi::apache').with({ :bind_address => nil, :listen_ssl => true, :horizon_cert => '/etc/pki/tls/certs/httpd.crt', @@ -193,7 +193,7 @@ describe 'horizon' do end it 'does not configure apache' do - should_not contain_class('horizon::wsgi::apache') + is_expected.not_to contain_class('horizon::wsgi::apache') end end @@ -208,7 +208,7 @@ describe 'horizon' do end it 'AVAILABLE_REGIONS is configured' do - verify_concat_fragment_contents(subject, 'local_settings.py', [ + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ "AVAILABLE_REGIONS = [", " ('http://region-1.example.com:5000/v2.0', 'Region-1'),", " ('http://region-2.example.com:5000/v2.0', 'Region-2'),", @@ -230,7 +230,7 @@ describe 'horizon' do end it 'POLICY_FILES_PATH and POLICY_FILES are configured' do - verify_concat_fragment_contents(subject, 'local_settings.py', [ + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ "POLICY_FILES_PATH = '/opt/openstack-dashboard'", "POLICY_FILES = {", " 'compute': 'nova_policy.json',", @@ -251,7 +251,7 @@ describe 'horizon' do end it 'uses the custom local_settings.py template' do - verify_concat_fragment_contents(subject, 'local_settings.py', [ + verify_concat_fragment_contents(catalogue, 'local_settings.py', [ '# Custom local_settings.py', 'DEBUG = True', "HORIZON_CONFIG = {", @@ -280,7 +280,7 @@ describe 'horizon' do }) end - it { should_not contain_file(params[:file_upload_temp_dir]) } + it { is_expected.not_to contain_file(params[:file_upload_temp_dir]) } end end diff --git a/spec/classes/horizon_wsgi_apache_spec.rb b/spec/classes/horizon_wsgi_apache_spec.rb index 7a7b9ef1..90ba6239 100644 --- a/spec/classes/horizon_wsgi_apache_spec.rb +++ b/spec/classes/horizon_wsgi_apache_spec.rb @@ -29,13 +29,13 @@ describe 'horizon::wsgi::apache' do context 'with default parameters' do it 'configures apache' do - should contain_class('horizon::params') - should contain_class('apache') - should contain_class('apache::mod::wsgi') - should contain_service('httpd').with_name(platforms_params[:http_service]) - should contain_file(platforms_params[:httpd_config_file]) - should contain_package('horizon').with_ensure('present') - should contain_apache__vhost('horizon_vhost').with( + is_expected.to contain_class('horizon::params') + is_expected.to contain_class('apache') + is_expected.to contain_class('apache::mod::wsgi') + is_expected.to contain_service('httpd').with_name(platforms_params[:http_service]) + is_expected.to contain_file(platforms_params[:httpd_config_file]) + is_expected.to contain_package('horizon').with_ensure('present') + is_expected.to contain_apache__vhost('horizon_vhost').with( 'servername' => 'some.host.tld', 'access_log_file' => 'horizon_access.log', 'error_log_file' => 'horizon_error.log', @@ -62,13 +62,13 @@ describe 'horizon::wsgi::apache' do end it 'configures apache' do - should contain_class('horizon::params') - should contain_class('apache') - should contain_class('apache::mod::wsgi') - should contain_service('httpd').with_name(platforms_params[:http_service]) - should contain_file(platforms_params[:httpd_config_file]) - should contain_package('horizon').with_ensure('present') - should contain_apache__vhost('horizon_vhost').with( + is_expected.to contain_class('horizon::params') + is_expected.to contain_class('apache') + is_expected.to contain_class('apache::mod::wsgi') + is_expected.to contain_service('httpd').with_name(platforms_params[:http_service]) + is_expected.to contain_file(platforms_params[:httpd_config_file]) + is_expected.to contain_package('horizon').with_ensure('present') + is_expected.to contain_apache__vhost('horizon_vhost').with( 'servername' => 'some.host.tld', 'access_log_file' => 'horizon_access.log', 'error_log_file' => 'horizon_error.log', @@ -100,9 +100,9 @@ describe 'horizon::wsgi::apache' do context 'with required parameters' do it 'configures apache for SSL' do - should contain_class('apache::mod::ssl') + is_expected.to contain_class('apache::mod::ssl') end - it { should contain_apache__vhost('horizon_ssl_vhost').with( + it { is_expected.to contain_apache__vhost('horizon_ssl_vhost').with( 'servername' => 'some.host.tld', 'access_log_file' => 'horizon_ssl_access.log', 'error_log_file' => 'horizon_ssl_error.log', @@ -121,7 +121,7 @@ describe 'horizon::wsgi::apache' do 'wsgi_script_aliases' => { platforms_params[:root_url] => '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi' } )} - it { should contain_apache__vhost('horizon_vhost').with( + it { is_expected.to contain_apache__vhost('horizon_vhost').with( 'servername' => 'some.host.tld', 'access_log_file' => 'horizon_access.log', 'error_log_file' => 'horizon_error.log', @@ -167,7 +167,7 @@ describe 'horizon::wsgi::apache' do end it 'configures apache' do - should contain_apache__vhost('horizon_vhost').with( + is_expected.to contain_apache__vhost('horizon_vhost').with( 'add_listen' => false, 'docroot' => '/tmp' ) @@ -201,7 +201,7 @@ describe 'horizon::wsgi::apache' do it_behaves_like 'apache for horizon' it { - should contain_class('apache::mod::wsgi').with(:wsgi_socket_prefix => '/var/run/wsgi') + is_expected.to contain_class('apache::mod::wsgi').with(:wsgi_socket_prefix => '/var/run/wsgi') } end diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index 51e11c0b..fec0eacc 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -1,5 +1,5 @@ shared_examples_for "a Puppet::Error" do |description| it "with message matching #{description.inspect}" do - expect { subject }.to raise_error(Puppet::Error, description) + expect { is_expected.to have_class_count(1) }.to raise_error(Puppet::Error, description) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b3bca421..605a8ad0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,5 +8,5 @@ end def verify_concat_fragment_contents(subject, title, expected_lines) content = subject.resource('concat::fragment', title).send(:parameters)[:content] - (content.split("\n") & expected_lines).should == expected_lines + expect(content.split("\n") & expected_lines).to eq(expected_lines) end diff --git a/spec/unit/puppet/parser/functions/os_any2array_spec.rb b/spec/unit/puppet/parser/functions/os_any2array_spec.rb index dd5bbe2c..70a99398 100644 --- a/spec/unit/puppet/parser/functions/os_any2array_spec.rb +++ b/spec/unit/puppet/parser/functions/os_any2array_spec.rb @@ -5,51 +5,51 @@ describe "the os_any2array function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do - Puppet::Parser::Functions.function("os_any2array").should == "function_os_any2array" + expect(Puppet::Parser::Functions.function("os_any2array")).to eq("function_os_any2array") end it "should return an empty array if there is less than 1 argument" do result = scope.function_os_any2array([]) - result.should(eq([])) + expect(result).to(eq([])) end it "should convert boolean true to [ true ] " do result = scope.function_os_any2array([true]) - result.should(eq([true])) + expect(result).to(eq([true])) end it "should convert one object to [object]" do result = scope.function_os_any2array(['one']) - result.should(eq(['one'])) + expect(result).to(eq(['one'])) end it "should convert multiple objects to [objects]" do result = scope.function_os_any2array(['one', 'two']) - result.should(eq(['one', 'two'])) + expect(result).to(eq(['one', 'two'])) end it "should return empty array it was called with" do result = scope.function_os_any2array([[]]) - result.should(eq([])) + expect(result).to(eq([])) end it "should return one-member array it was called with" do result = scope.function_os_any2array([['string']]) - result.should(eq(['string'])) + expect(result).to(eq(['string'])) end it "should return multi-member array it was called with" do result = scope.function_os_any2array([['one', 'two']]) - result.should(eq(['one', 'two'])) + expect(result).to(eq(['one', 'two'])) end it "should return members of a hash it was called with" do result = scope.function_os_any2array([{ 'key' => 'value' }]) - result.should(eq(['key', 'value'])) + expect(result).to(eq(['key', 'value'])) end it "should return an empty array if it was called with an empty hash" do result = scope.function_os_any2array([{ }]) - result.should(eq([])) + expect(result).to(eq([])) end end