From 33922a4ec7a8c204a17e0c3017eea21faa220f39 Mon Sep 17 00:00:00 2001 From: tphoney Date: Fri, 14 Jul 2017 10:14:04 +0100 Subject: FM-6239 clean up for puppet 5.tests/deprecation --- spec/functions/deep_merge_spec.rb | 2 +- spec/functions/strftime_spec.rb | 4 ++-- spec/functions/unique_spec.rb | 46 ++++++++++++++++++++------------------- 3 files changed, 27 insertions(+), 25 deletions(-) (limited to 'spec/functions') diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index c91a07e..819e025 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -4,7 +4,7 @@ describe 'deep_merge' do it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } it { is_expected.to run.with_params({ 'key' => 'value' }).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } it { is_expected.to run.with_params({}, '2').and_raise_error(Puppet::ParseError, /unexpected argument type String/) } - it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument type Fixnum/) } + it { is_expected.to run.with_params({}, 2).and_raise_error(Puppet::ParseError, /unexpected argument/) } it { is_expected.to run.with_params({}, '').and_return({}) } it { is_expected.to run.with_params({}, {}).and_return({}) } it { is_expected.to run.with_params({}, {}, {}).and_return({}) } diff --git a/spec/functions/strftime_spec.rb b/spec/functions/strftime_spec.rb index e76774a..41cda6a 100755 --- a/spec/functions/strftime_spec.rb +++ b/spec/functions/strftime_spec.rb @@ -14,9 +14,9 @@ describe 'strftime' do expect(result.to_i).to(be > 1311953157) end - it "using %s should be lower then 1.5 trillion" do + it "using %s should be greater than 1.5 trillion" do result = scope.function_strftime(["%s"]) - expect(result.to_i).to(be < 1500000000) + expect(result.to_i).to(be > 1500000000) end it "should return a date when given %Y-%m-%d" do diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb index 7955acb..76932ec 100755 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -1,29 +1,31 @@ require 'spec_helper' describe 'unique' do - describe 'signature validation' do - it { is_expected.not_to eq(nil) } - it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } - it { - pending("Current implementation ignores parameters after the first.") - is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) - } - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } - end + if Puppet.version.to_f < 5.0 + describe 'signature validation' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { + pending("Current implementation ignores parameters after the first.") + is_expected.to run.with_params([], 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) + } + it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } + it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) } + end - context 'when called with an array' do - it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } - it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } - end + context 'when called with an array' do + it { is_expected.to run.with_params([]).and_return([]) } + it { is_expected.to run.with_params(['a']).and_return(['a']) } + it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } + it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } + end - context 'when called with a string' do - it { is_expected.to run.with_params('').and_return('') } - it { is_expected.to run.with_params('a').and_return('a') } - it { is_expected.to run.with_params('aaba').and_return('ab') } - it { is_expected.to run.with_params('ããъã').and_return('ãъ') } + context 'when called with a string' do + it { is_expected.to run.with_params('').and_return('') } + it { is_expected.to run.with_params('a').and_return('a') } + it { is_expected.to run.with_params('aaba').and_return('ab') } + it { is_expected.to run.with_params('ããъã').and_return('ãъ') } + end end end -- cgit v1.2.3