diff --git a/manifests/fragment.pp b/manifests/fragment.pp index 3382e16..c4a4cdf 100644 --- a/manifests/fragment.pp +++ b/manifests/fragment.pp @@ -35,7 +35,7 @@ define concat::fragment( $group = undef, $backup = undef ) { - validate_absolute_path($target) + validate_string($target) validate_re($ensure, '^$|^present$|^absent$|^file$|^directory$') validate_string($content) validate_string($source) diff --git a/spec/system/symbolic_name_spec.rb b/spec/system/symbolic_name_spec.rb new file mode 100644 index 0000000..2b687c0 --- /dev/null +++ b/spec/system/symbolic_name_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper_system' + +describe 'symbolic name' do + pp=" + concat { 'not_abs_path': + path => '/tmp/file', + } + + concat::fragment { '1': + target => 'not_abs_path', + content => '1', + order => '01', + } + + concat::fragment { '2': + target => 'not_abs_path', + content => '2', + order => '02', + } + " + + context puppet_apply(pp) do + its(:stderr) { should be_empty } + its(:exit_code) { should_not == 1 } + its(:refresh) { should be_nil } + its(:stderr) { should be_empty } + its(:exit_code) { should be_zero } + end + + describe file('/tmp/file') do + it { should be_file } + it { should contain '1' } + it { should contain '2' } + end +end diff --git a/spec/unit/defines/concat_fragment_spec.rb b/spec/unit/defines/concat_fragment_spec.rb index ebb0807..8206920 100644 --- a/spec/unit/defines/concat_fragment_spec.rb +++ b/spec/unit/defines/concat_fragment_spec.rb @@ -44,22 +44,30 @@ describe 'concat::fragment', :type => :define do end end - context 'target =>' do - context '/etc/motd' do - it_behaves_like 'fragment', 'motd_header', { + context 'title' do + ['0', '1', 'a', 'z'].each do |title| + it_behaves_like 'fragment', title, { :target => '/etc/motd', } end + end # title - ['./etc/motd', 'etc/motd', false].each do |target| + context 'target =>' do + ['./etc/motd', 'etc/motd', 'motd_header'].each do |target| context target do - let(:title) { 'motd_header' } - let(:facts) {{ :concat_basedir => '/tmp' }} - let(:params) {{ :target => target }} + it_behaves_like 'fragment', target, { + :target => '/etc/motd', + } + end + end - it 'should fail' do - expect { should }.to raise_error(Puppet::Error, /is not an absolute path/) - end + context 'false' do + let(:title) { 'motd_header' } + let(:facts) {{ :concat_basedir => '/tmp' }} + let(:params) {{ :target => false }} + + it 'should fail' do + expect { should }.to raise_error(Puppet::Error, /is not a string/) end end end # target =>