X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fdelete_spec.rb;h=df5ee7a404440698b03279a023d9bf73ca9539f9;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=4e37865ae052972bcea72fdb4a9558496d094af8;hpb=6963202b4b62c2816655ac9532521b018fdf83bd;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/delete_spec.rb b/3rdparty/modules/stdlib/spec/functions/delete_spec.rb old mode 100755 new mode 100644 index 4e37865ae..df5ee7a40 --- a/3rdparty/modules/stdlib/spec/functions/delete_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/delete_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' describe 'delete' do it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } it { is_expected.to run.with_params([], 'two') } - it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError) } - it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError) } + it { is_expected.to run.with_params([], 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be an Array, String, or Hash}) } describe 'deleting from an array' do it { is_expected.to run.with_params([], '').and_return([]) } @@ -40,37 +40,40 @@ describe 'delete' do describe 'deleting from an array' do it { is_expected.to run.with_params({}, '').and_return({}) } it { is_expected.to run.with_params({}, 'key').and_return({}) } - it { is_expected.to run.with_params({'key' => 'value'}, 'key').and_return({}) } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, 'key2') \ - .and_return( {'key1' => 'value1', 'key3' => 'value3'}) + it { is_expected.to run.with_params({ 'key' => 'value' }, 'key').and_return({}) } + it { + is_expected.to run \ + .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, 'key2') \ + .and_return('key1' => 'value1', 'key3' => 'value3') } - it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \ - .and_return( {'key3' => 'value3'}) + it { + is_expected.to run \ + .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \ + .and_return('key3' => 'value3') } - it { is_expected.to run \ - .with_params({'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3'}, ['ĸəұ1', 'ĸəұ2']) \ - .and_return( {'ĸəұ3' => 'νãŀủĕ3'}) + it { + is_expected.to run \ + .with_params({ 'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3' }, ['ĸəұ1', 'ĸəұ2']) \ + .and_return('ĸəұ3' => 'νãŀủĕ3') } end - it "should leave the original array intact" do - argument1 = ['one','two','three'] + it 'leaves the original array intact' do + argument1 = ['one', 'two', 'three'] original1 = argument1.dup - result = subject.call([argument1,'two']) + _result = subject.execute(argument1, 'two') expect(argument1).to eq(original1) end - it "should leave the original string intact" do + it 'leaves the original string intact' do argument1 = 'onetwothree' original1 = argument1.dup - result = subject.call([argument1,'two']) + _result = subject.execute(argument1, 'two') expect(argument1).to eq(original1) end - it "should leave the original hash intact" do - argument1 = {'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'} + it 'leaves the original hash intact' do + argument1 = { 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' } original1 = argument1.dup - result = subject.call([argument1,'key2']) + _result = subject.execute(argument1, 'key2') expect(argument1).to eq(original1) end end