X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fconcat%2Fspec%2Facceptance%2Forder_spec.rb;h=307502b180b7c5560f6805520ef3fc3ad4678db6;hp=b746b1c9c56b641bcbf0a7120cc81c1337bfa10f;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/concat/spec/acceptance/order_spec.rb b/3rdparty/modules/concat/spec/acceptance/order_spec.rb index b746b1c9c..307502b18 100644 --- a/3rdparty/modules/concat/spec/acceptance/order_spec.rb +++ b/3rdparty/modules/concat/spec/acceptance/order_spec.rb @@ -1,123 +1,66 @@ require 'spec_helper_acceptance' describe 'concat order' do - basedir = default.tmpdir('concat') - - context '=> ' do - shared_examples 'sortby' do |order_by, match_output| - pp = <<-EOS - concat { '#{basedir}/foo': - order => '#{order_by}' + before(:all) do + @basedir = setup_test_directory + end + describe 'sortby alpha' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': + order => 'alpha' } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string1', order => '1', } concat::fragment { '2': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string2', order => '2', } concat::fragment { '10': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string10', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match match_output } - end + MANIFEST end - describe 'alpha' do - it_behaves_like 'sortby', 'alpha', /string1string10string2/ - end - - describe 'numeric' do - it_behaves_like 'sortby', 'numeric', /string1string2string10/ + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string1string10string2} end end -end # concat order -describe 'concat::fragment order' do - basedir = default.tmpdir('concat') - - context '=> reverse order' do - shared_examples 'order_by' do |order_by, match_output| - pp = <<-EOS - concat { '#{basedir}/foo': - order => '#{order_by}' + describe 'sortby numeric' do + let(:pp) do + <<-MANIFEST + concat { '#{@basedir}/foo': + order => 'numeric' } concat::fragment { '1': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string1', - order => '15', - } - concat::fragment { '2': - target => '#{basedir}/foo', - content => 'string2', - # default order 10 - } - concat::fragment { '3': - target => '#{basedir}/foo', - content => 'string3', order => '1', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) - end - - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match match_output } - end - end - describe 'alpha' do - it_should_behave_like 'order_by', 'alpha', /string3string2string1/ - end - describe 'numeric' do - it_should_behave_like 'order_by', 'numeric', /string3string2string1/ - end - end - - context '=> normal order' do - pp = <<-EOS - concat { '#{basedir}/foo': } - concat::fragment { '1': - target => '#{basedir}/foo', - content => 'string1', - order => '01', - } concat::fragment { '2': - target => '#{basedir}/foo', + target => '#{@basedir}/foo', content => 'string2', - order => '02' + order => '2', } - concat::fragment { '3': - target => '#{basedir}/foo', - content => 'string3', - order => '03', + concat::fragment { '10': + target => '#{@basedir}/foo', + content => 'string10', } - EOS - - it 'applies the manifest twice with no stderr' do - apply_manifest(pp, :catch_failures => true) - apply_manifest(pp, :catch_changes => true) + MANIFEST end - describe file("#{basedir}/foo") do - it { should be_file } - its(:content) { should match /string1string2string3/ } + it 'applies the manifest twice with no stderr' do + idempotent_apply(pp) + expect(file("#{@basedir}/foo")).to be_file + expect(file("#{@basedir}/foo").content).to match %r{string1string2string10} end end -end # concat::fragment order +end