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: * Upgrade and pin rspec-puppet from 1.0.1 to 2.0.0 * 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 * Clean Gemfile (remove over-specificication of runtime deps of puppetlabs_spec_helper) Change-Id: Ida94605916fe26dd4c5fb328f79c4e787d29dcf5 Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
@@ -32,39 +32,39 @@ describe 'neutron::agents::dhcp' do
|
||||
default_params.merge(params)
|
||||
end
|
||||
|
||||
it { should contain_class('neutron::params') }
|
||||
it { is_expected.to contain_class('neutron::params') }
|
||||
|
||||
it_configures 'dnsmasq dhcp_driver'
|
||||
|
||||
it 'configures dhcp_agent.ini' do
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/debug').with_value(p[:debug]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/state_path').with_value(p[:state_path]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/resync_interval').with_value(p[:resync_interval]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/dhcp_driver').with_value(p[:dhcp_driver]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/root_helper').with_value(p[:root_helper]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/dhcp_delete_namespaces').with_value(p[:dhcp_delete_namespaces]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(p[:enable_isolated_metadata]);
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value(p[:enable_metadata_network]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/debug').with_value(p[:debug]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/state_path').with_value(p[:state_path]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/resync_interval').with_value(p[:resync_interval]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/interface_driver').with_value(p[:interface_driver]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dhcp_driver').with_value(p[:dhcp_driver]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/root_helper').with_value(p[:root_helper]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dhcp_delete_namespaces').with_value(p[:dhcp_delete_namespaces]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(p[:enable_isolated_metadata]);
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value(p[:enable_metadata_network]);
|
||||
end
|
||||
|
||||
it 'installs neutron dhcp agent package' do
|
||||
if platform_params.has_key?(:dhcp_agent_package)
|
||||
should contain_package('neutron-dhcp-agent').with(
|
||||
is_expected.to contain_package('neutron-dhcp-agent').with(
|
||||
:name => platform_params[:dhcp_agent_package],
|
||||
:ensure => p[:package_ensure]
|
||||
)
|
||||
should contain_package('neutron').with_before(/Package\[neutron-dhcp-agent\]/)
|
||||
should contain_package('neutron-dhcp-agent').with_before(/Neutron_dhcp_agent_config\[.+\]/)
|
||||
should contain_package('neutron-dhcp-agent').with_before(/Neutron_config\[.+\]/)
|
||||
is_expected.to contain_package('neutron').with_before(/Package\[neutron-dhcp-agent\]/)
|
||||
is_expected.to contain_package('neutron-dhcp-agent').with_before(/Neutron_dhcp_agent_config\[.+\]/)
|
||||
is_expected.to contain_package('neutron-dhcp-agent').with_before(/Neutron_config\[.+\]/)
|
||||
else
|
||||
should contain_package('neutron').with_before(/Neutron_dhcp_agent_config\[.+\]/)
|
||||
is_expected.to contain_package('neutron').with_before(/Neutron_dhcp_agent_config\[.+\]/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'configures neutron dhcp agent service' do
|
||||
should contain_service('neutron-dhcp-service').with(
|
||||
is_expected.to contain_service('neutron-dhcp-service').with(
|
||||
:name => platform_params[:dhcp_agent_service],
|
||||
:enable => true,
|
||||
:ensure => 'running',
|
||||
@@ -77,7 +77,7 @@ describe 'neutron::agents::dhcp' do
|
||||
params.merge!(:manage_service => false)
|
||||
end
|
||||
it 'should not start/stop service' do
|
||||
should contain_service('neutron-dhcp-service').without_ensure
|
||||
is_expected.to contain_service('neutron-dhcp-service').without_ensure
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,8 +86,8 @@ describe 'neutron::agents::dhcp' do
|
||||
params.merge!(:enable_isolated_metadata => true, :enable_metadata_network => false)
|
||||
end
|
||||
it 'should enable isolated_metadata only' do
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true');
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('false');
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true');
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('false');
|
||||
end
|
||||
end
|
||||
|
||||
@@ -96,8 +96,8 @@ describe 'neutron::agents::dhcp' do
|
||||
params.merge!(:enable_isolated_metadata => true, :enable_metadata_network => true)
|
||||
end
|
||||
it 'should enable both isolated_metadata and metadata_network' do
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true');
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('true');
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true');
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('true');
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,9 +105,8 @@ describe 'neutron::agents::dhcp' do
|
||||
before :each do
|
||||
params.merge!(:enable_isolated_metadata => false, :enable_metadata_network => true)
|
||||
end
|
||||
it 'should fails to configure metadata_network without isolated_metadata' do
|
||||
expect { subject }.to raise_error(Puppet::Error, /enable_metadata_network to true requires enable_isolated_metadata also enabled./)
|
||||
end
|
||||
|
||||
it_raises 'a Puppet::Error', /enable_metadata_network to true requires enable_isolated_metadata also enabled./
|
||||
end
|
||||
end
|
||||
|
||||
@@ -118,21 +117,21 @@ describe 'neutron::agents::dhcp' do
|
||||
)
|
||||
end
|
||||
it 'configures dnsmasq_config_file' do
|
||||
should contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_config_file').with_value(params[:dnsmasq_config_file])
|
||||
is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_config_file').with_value(params[:dnsmasq_config_file])
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'dnsmasq dhcp_driver' do
|
||||
it 'installs dnsmasq packages' do
|
||||
if platform_params.has_key?(:dhcp_agent_package)
|
||||
should contain_package(platform_params[:dnsmasq_base_package]).with_before('Package[neutron-dhcp-agent]')
|
||||
should contain_package(platform_params[:dnsmasq_utils_package]).with_before('Package[neutron-dhcp-agent]')
|
||||
is_expected.to contain_package(platform_params[:dnsmasq_base_package]).with_before('Package[neutron-dhcp-agent]')
|
||||
is_expected.to contain_package(platform_params[:dnsmasq_utils_package]).with_before('Package[neutron-dhcp-agent]')
|
||||
end
|
||||
should contain_package(platform_params[:dnsmasq_base_package]).with(
|
||||
is_expected.to contain_package(platform_params[:dnsmasq_base_package]).with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:dnsmasq_base_package]
|
||||
)
|
||||
should contain_package(platform_params[:dnsmasq_utils_package]).with(
|
||||
is_expected.to contain_package(platform_params[:dnsmasq_utils_package]).with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:dnsmasq_utils_package]
|
||||
)
|
||||
|
Reference in New Issue
Block a user