Skip to content

Commit 6394b3f

Browse files
committed
Conditionalize specs, make readme deprecations similar
1 parent 953ddb3 commit 6394b3f

File tree

18 files changed

+48
-151
lines changed

18 files changed

+48
-151
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ Converts the case of a string or of all strings in an array to lowercase.
11631163

11641164
#### `empty`
11651165

1166-
**Deprecated. Puppet 5.5.0 has introduced a built in `empty` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1166+
**Deprecated: This function has been replaced with a built-in [`empty`](https://docs.puppet.com/puppet/latest/function.html#empty) function as of Puppet 5.5.0.**
11671167

11681168
Returns `true` if the argument is an array or hash that contains no elements, or an empty string. Returns `false` when the argument is a numerical value.
11691169

@@ -1276,7 +1276,7 @@ fact('vmware."VRA.version"')
12761276

12771277
#### `flatten`
12781278

1279-
**Deprecated. Puppet 5.5.0 has introduced a built in `flatten` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1279+
**Deprecated: This function has been replaced with a built-in [`flatten`](https://docs.puppet.com/puppet/latest/function.html#flatten) function as of Puppet 5.5.0.**
12801280

12811281
Flattens deeply nested arrays and returns a single flat array as a result.
12821282

@@ -1635,7 +1635,7 @@ Returns `true` if the variable passed to this function is a string.
16351635

16361636
#### `join`
16371637

1638-
**Deprecated. Puppet 5.5.0 has introduced a built in `join` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1638+
**Deprecated: This function has been replaced with a built-in [`join`](https://docs.puppet.com/puppet/latest/function.html#join) function as of Puppet 5.5.0.**
16391639

16401640
Joins an array into a string using a separator. For example, `join(['a','b','c'], ",")` results in: "a,b,c".
16411641

@@ -1653,15 +1653,15 @@ For example, `join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ")` results in ["a i
16531653

16541654
#### `keys`
16551655

1656-
**Deprecated. Puppet 5.5.0 has introduced a built in `keys` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1656+
**Deprecated: This function has been replaced with a built-in [`keys`](https://docs.puppet.com/puppet/latest/function.html#keys) function as of Puppet 5.5.0.**
16571657

16581658
Returns the keys of a hash as an array.
16591659

16601660
*Type*: rvalue.
16611661

16621662
#### `length`
16631663

1664-
**Deprecated. Puppet 5.5.0 has introduced a built in `length` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
1664+
**Deprecated: This function has been replaced with a built-in [`length`](https://docs.puppet.com/puppet/latest/function.html#length) function as of Puppet 5.5.0.**
16651665

16661666
Returns the length of a given string, array or hash. Replaces the deprecated `size()` function.
16671667

@@ -2784,7 +2784,7 @@ validate_x509_rsa_key_pair($cert, $key)
27842784

27852785
#### `values`
27862786

2787-
**Deprecated. Puppet 5.5.0 has introduced a built in `values` function, which will take precedence over the stdlib function. See [Puppet 5.5.0 Release Notes](https://puppet.com/docs/puppet/5.5/release_notes.html#new-features).**
2787+
**Deprecated: This function has been replaced with a built-in [`values`](https://docs.puppet.com/puppet/latest/function.html#values) function as of Puppet 5.5.0.**
27882788

27892789
Returns the values of a given hash.
27902790

lib/puppet/functions/length.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ def length(value)
1111
end
1212
result
1313
end
14-
Puppet.deprecation_warning('The length function is deprecated. This function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.')
1514
end

lib/puppet/parser/functions/empty.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ module Puppet::Parser::Functions
77
DOC
88
) do |arguments|
99

10-
function_deprecation([:empty, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.'])
11-
1210
raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
1311
value = arguments[0]
1412

lib/puppet/parser/functions/flatten.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ module Puppet::Parser::Functions
1414
DOC
1515
) do |arguments|
1616

17-
function_deprecation([:flatten, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes'])
18-
1917
raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
2018

2119
array = arguments[0]

lib/puppet/parser/functions/join.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ module Puppet::Parser::Functions
1313
DOC
1414
) do |arguments|
1515

16-
function_deprecation([:join, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes'])
17-
1816
# Technically we support two arguments but only first is mandatory ...
1917
raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
2018

lib/puppet/parser/functions/keys.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ module Puppet::Parser::Functions
77
DOC
88
) do |arguments|
99

10-
function_deprecation([:keys, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.'])
11-
1210
raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
1311

1412
hash = arguments[0]

lib/puppet/parser/functions/values.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ module Puppet::Parser::Functions
2020
DOC
2121
) do |arguments|
2222

23-
function_deprecation([:values, 'This method is deprecated, this function is now shipped with Puppet in versions 5.5.0 and later. For more information please see Puppet 5.5.0 Release Notes.'])
24-
2523
raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
2624

2725
hash = arguments[0]

spec/acceptance/empty_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'empty function' do
3+
describe 'empty function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
describe 'success' do
55
pp1 = <<-DOC
66
$a = ''

spec/acceptance/flatten_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'flatten function' do
3+
describe 'flatten function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
describe 'success' do
55
pp1 = <<-DOC
66
$a = ["a","b",["c",["d","e"],"f","g"]]

spec/acceptance/join_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'join function' do
3+
describe 'join function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
describe 'success' do
55
pp = <<-DOC
66
$a = ['aaa','bbb','ccc']

spec/acceptance/keys_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'keys function' do
3+
describe 'keys function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
describe 'success' do
55
pp = <<-DOC
66
$a = {'aaa'=>'bbb','ccc'=>'ddd'}

spec/acceptance/values_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'values function' do
3+
describe 'values function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
describe 'success' do
55
pp1 = <<-DOC
66
$arg = {
@@ -23,8 +23,7 @@
2323
notice(inline_template('<%= @output.inspect %>'))
2424
DOC
2525
it 'handles non-hash arguments' do
26-
expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash}) if return_puppet_version < '5.5.0'
27-
expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{expects a Hash value}) if return_puppet_version >= '5.5.0'
26+
expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash})
2827
end
2928
end
3029
end

spec/functions/empty_spec.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require 'spec_helper'
22

3-
describe 'empty' do
3+
describe 'empty', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
66
it {
77
pending('Current implementation ignores parameters after the first.')
88
is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError)
@@ -19,21 +19,4 @@
1919

2020
it { is_expected.to run.with_params({}).and_return(true) }
2121
it { is_expected.to run.with_params('key' => 'value').and_return(false) }
22-
23-
context 'with deprecation warning' do
24-
after(:each) do
25-
ENV.delete('STDLIB_LOG_DEPRECATIONS')
26-
end
27-
# Checking for deprecation warning, which should only be provoked when the env variable for it is set.
28-
it 'displays a single deprecation' do
29-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
30-
scope.expects(:warning).with(includes('This method is deprecated'))
31-
is_expected.to run.with_params(0).and_return(false)
32-
end
33-
it 'displays no warning for deprecation' do
34-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
35-
scope.expects(:warning).with(includes('This method is deprecated')).never
36-
is_expected.to run.with_params(0).and_return(false)
37-
end
38-
end
3922
end

spec/functions/flatten_spec.rb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,15 @@
11
require 'spec_helper'
22

3-
# rubocop:disable Style/WordArray, Layout/SpaceAfterComma
4-
describe 'flatten' do
3+
describe 'flatten', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
54
it { is_expected.not_to eq(nil) }
6-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
7-
it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
8-
it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
9-
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) } if Puppet.version < '5.5.0'
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError) }
6+
it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError) }
7+
it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError) }
8+
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError) }
109
it { is_expected.to run.with_params([]).and_return([]) }
1110
it { is_expected.to run.with_params(['one']).and_return(['one']) }
1211
it { is_expected.to run.with_params([['one']]).and_return(['one']) }
1312
it { is_expected.to run.with_params(%w[a b c d e f g]).and_return(%w[a b c d e f g]) }
1413
it { is_expected.to run.with_params([['a', 'b', ['c', %w[d e], 'f', 'g']]]).and_return(%w[a b c d e f g]) }
1514
it { is_expected.to run.with_params(['ã', 'β', ['ĉ', %w[đ ƒ ġ]]]).and_return(%w[ã β ĉ đ ƒ ġ]) }
16-
17-
context 'with deprecation warning' do
18-
after(:each) do
19-
ENV.delete('STDLIB_LOG_DEPRECATIONS')
20-
end
21-
# Checking for deprecation warning, which should only be provoked when the env variable for it is set.
22-
it 'displays a single deprecation' do
23-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
24-
scope.expects(:warning).with(includes('This method is deprecated'))
25-
is_expected.to run.with_params(['a', ['b', ['c']]]).and_return(['a','b','c'])
26-
end
27-
it 'displays no warning for deprecation' do
28-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
29-
scope.expects(:warning).with(includes('This method is deprecated')).never
30-
is_expected.to run.with_params(['a', ['b', ['c']]]).and_return(['a','b','c'])
31-
end
32-
end
3315
end

spec/functions/join_spec.rb

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
require 'spec_helper'
22

3-
describe 'join' do
3+
describe 'join', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } if Puppet.version < '5.5.0'
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
66
it {
77
pending('Current implementation ignores parameters after the second.')
88
is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
99
}
10-
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array to work with}) } if Puppet.version < '5.5.0'
11-
it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{Requires string to work with}) } if Puppet.version < '5.5.0'
10+
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array to work with}) }
11+
it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{Requires string to work with}) }
1212

1313
it { is_expected.to run.with_params([]).and_return('') }
1414
it { is_expected.to run.with_params([], ':').and_return('') }
@@ -17,21 +17,4 @@
1717
it { is_expected.to run.with_params(%w[one two three]).and_return('onetwothree') }
1818
it { is_expected.to run.with_params(%w[one two three], ':').and_return('one:two:three') }
1919
it { is_expected.to run.with_params(%w[ōŋể ŧשợ ţђŕẽё], ':').and_return('ōŋể:ŧשợ:ţђŕẽё') }
20-
21-
context 'with deprecation warning' do
22-
after(:each) do
23-
ENV.delete('STDLIB_LOG_DEPRECATIONS')
24-
end
25-
# Checking for deprecation warning, which should only be provoked when the env variable for it is set.
26-
it 'displays a single deprecation' do
27-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
28-
scope.expects(:warning).with(includes('This method is deprecated'))
29-
is_expected.to run.with_params([]).and_return('')
30-
end
31-
it 'displays no warning for deprecation' do
32-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
33-
scope.expects(:warning).with(includes('This method is deprecated')).never
34-
is_expected.to run.with_params([]).and_return('')
35-
end
36-
end
3720
end

spec/functions/keys_spec.rb

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,24 @@
11
require 'spec_helper'
22

3-
describe 'keys' do
3+
describe 'keys', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
it { is_expected.not_to eq(nil) }
5-
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } if Puppet.version < '5.5.0'
5+
it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
66
it {
77
pending('Current implementation ignores parameters after the first.')
88
is_expected.to run.with_params({}, {}).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
99
}
10-
it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } if Puppet.version < '5.5.0'
11-
it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } if Puppet.version < '5.5.0'
12-
it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) } if Puppet.version < '5.5.0'
10+
it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
11+
it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
12+
it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires hash to work with}) }
1313
it { is_expected.to run.with_params({}).and_return([]) }
1414
it { is_expected.to run.with_params('key' => 'value').and_return(['key']) }
15-
16-
if Puppet.version < '5.5.0'
17-
it 'returns the array of keys' do
18-
result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }])
19-
expect(result).to match_array(%w[key1 key2])
20-
end
21-
22-
it 'runs with UTF8 and double byte characters', :if => Puppet.version < '5.5.0' do
23-
result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }])
24-
expect(result).to match_array(%w[ҝểү キー])
25-
end
15+
it 'returns the array of keys' do
16+
result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }])
17+
expect(result).to match_array(%w[key1 key2])
2618
end
2719

28-
context 'with deprecation warning' do
29-
after(:each) do
30-
ENV.delete('STDLIB_LOG_DEPRECATIONS')
31-
end
32-
# Checking for deprecation warning, which should only be provoked when the env variable for it is set.
33-
it 'displays a single deprecation' do
34-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
35-
scope.expects(:warning).with(includes('This method is deprecated'))
36-
is_expected.to run.with_params({}).and_return([])
37-
end
38-
it 'displays no warning for deprecation' do
39-
ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
40-
scope.expects(:warning).with(includes('This method is deprecated')).never
41-
is_expected.to run.with_params({}).and_return([])
42-
end
20+
it 'runs with UTF8 and double byte characters' do
21+
result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }])
22+
expect(result).to match_array(%w[ҝểү キー])
4323
end
4424
end

spec/functions/length_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require 'spec_helper'
22

3-
describe 'length' do
3+
describe 'length', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
44
it { is_expected.not_to eq(nil) }
55
it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'length' expects 1 argument, got none}) }
66
it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, %r{'length' expects 1 argument, got 2}) }
7-
it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, %r{expects a value of type String, Array, or Hash, got Integer}) } if Puppet.version < '5.5.0'
8-
it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, %r{expects a value of type String, Array, or Hash, got Boolean}) } if Puppet.version < '5.5.0'
7+
it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, %r{expects a value of type String, Array, or Hash, got Integer}) }
8+
it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, %r{expects a value of type String, Array, or Hash, got Boolean}) }
99
it { is_expected.to run.with_params('1').and_return(1) }
1010
it { is_expected.to run.with_params('1.0').and_return(3) }
1111
it { is_expected.to run.with_params([]).and_return(0) }

0 commit comments

Comments
 (0)