From 1477e6f7a31b1fbc6e35896c7a4b4c202e626324 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 26 Nov 2019 19:45:59 +0100 Subject: [PATCH] Clean up requirements_spec.rb A lot of contexts and describes are redundant. --- spec/defines/requirements_spec.rb | 68 ++++++++++++------------------- 1 file changed, 27 insertions(+), 41 deletions(-) diff --git a/spec/defines/requirements_spec.rb b/spec/defines/requirements_spec.rb index 29119422..c57f076d 100644 --- a/spec/defines/requirements_spec.rb +++ b/spec/defines/requirements_spec.rb @@ -2,7 +2,7 @@ describe 'python::requirements', type: :define do on_supported_os.each do |os, facts| - context "on #{os} " do + context "on #{os}" do let :facts do facts end @@ -11,52 +11,38 @@ '/requirements.txt' end - context 'on Debian OS' do - describe 'requirements as' do - context '/requirements.txt' do - let :params do - { - requirements: '/requirements.txt' - } - end + context 'with /requirements.txt' do + let :params do + { + requirements: '/requirements.txt' + } + end - it { is_expected.to contain_file('/requirements.txt').with_mode('0644') } - end - context '/requirements.txt' do - let :params do - { - requirements: '/requirements.txt', - manage_requirements: false - } - end - - it { is_expected.not_to contain_file('/requirements.txt') } - end + it { is_expected.to contain_file('/requirements.txt').with_mode('0644') } - describe 'with owner' do - context 'bob:bob' do - let :params do - { - owner: 'bob', - group: 'bob' - } - end - - it do - expect do - is_expected.to compile - end.to raise_error(%r{root user must be used when virtualenv is system}) - end - end - end + context 'with manage_requirements => false' do + let(:params) { super().merge(manage_requirements: false) } + + it { is_expected.not_to contain_file('/requirements.txt') } + end + end - describe 'with owner' do - context 'default' do - it { is_expected.to contain_file('/requirements.txt').with_owner('root').with_group('root') } - end + describe 'with owner' do + context 'bob:bob' do + let :params do + { + owner: 'bob', + group: 'bob' + } end + + it { is_expected.to compile.and_raise_error(%r{root user must be used when virtualenv is system}) } end end + + context 'default' do + it { is_expected.to contain_file('/requirements.txt').with_owner('root').with_group('root') } + end end end end