From 21e7ce8fc3cdacab50b71d1973d7c80ed0543fd3 Mon Sep 17 00:00:00 2001 From: Paula McMaw Date: Wed, 6 Dec 2017 14:09:26 +0000 Subject: [PATCH] Addressing rubocop errors --- lib/facter/facter_dot_d.rb | 16 ++++------ lib/puppet/parser/functions/abs.rb | 4 +-- lib/puppet/parser/functions/any2array.rb | 4 +-- lib/puppet/parser/functions/any2bool.rb | 6 ++-- lib/puppet/parser/functions/assert_private.rb | 4 +-- lib/puppet/parser/functions/base64.rb | 4 +-- lib/puppet/parser/functions/basename.rb | 4 +-- lib/puppet/parser/functions/bool2num.rb | 4 +-- lib/puppet/parser/functions/bool2str.rb | 4 +-- lib/puppet/parser/functions/camelcase.rb | 4 +-- lib/puppet/parser/functions/capitalize.rb | 4 +-- lib/puppet/parser/functions/ceiling.rb | 4 +-- lib/puppet/parser/functions/chomp.rb | 4 +-- lib/puppet/parser/functions/chop.rb | 4 +-- lib/puppet/parser/functions/clamp.rb | 4 +-- lib/puppet/parser/functions/concat.rb | 4 +-- lib/puppet/parser/functions/convert_base.rb | 4 +-- lib/puppet/parser/functions/count.rb | 4 +-- lib/puppet/parser/functions/deep_merge.rb | 4 +-- .../parser/functions/defined_with_params.rb | 4 +-- lib/puppet/parser/functions/delete.rb | 4 +-- lib/puppet/parser/functions/delete_at.rb | 4 +-- lib/puppet/parser/functions/delete_regex.rb | 4 +-- .../parser/functions/delete_undef_values.rb | 4 +-- lib/puppet/parser/functions/delete_values.rb | 4 +-- lib/puppet/parser/functions/deprecation.rb | 4 +-- lib/puppet/parser/functions/difference.rb | 4 +-- lib/puppet/parser/functions/dig.rb | 4 +-- lib/puppet/parser/functions/dig44.rb | 6 ++-- lib/puppet/parser/functions/dirname.rb | 4 +-- lib/puppet/parser/functions/dos2unix.rb | 4 +-- lib/puppet/parser/functions/downcase.rb | 4 +-- lib/puppet/parser/functions/empty.rb | 4 +-- lib/puppet/parser/functions/enclose_ipv6.rb | 4 +-- .../parser/functions/ensure_packages.rb | 4 +-- .../parser/functions/ensure_resource.rb | 4 +-- .../parser/functions/ensure_resources.rb | 4 +-- lib/puppet/parser/functions/flatten.rb | 4 +-- lib/puppet/parser/functions/floor.rb | 4 +-- lib/puppet/parser/functions/fqdn_uuid.rb | 5 ++- .../parser/functions/get_module_path.rb | 4 +-- lib/puppet/parser/functions/getparam.rb | 4 +-- lib/puppet/parser/functions/getvar.rb | 4 +-- lib/puppet/parser/functions/glob.rb | 4 +-- lib/puppet/parser/functions/grep.rb | 4 +-- .../parser/functions/has_interface_with.rb | 4 +-- lib/puppet/parser/functions/has_ip_address.rb | 4 +-- lib/puppet/parser/functions/has_ip_network.rb | 4 +-- lib/puppet/parser/functions/has_key.rb | 4 +-- lib/puppet/parser/functions/hash.rb | 4 +-- lib/puppet/parser/functions/intersection.rb | 4 +-- .../parser/functions/is_absolute_path.rb | 4 +-- lib/puppet/parser/functions/is_array.rb | 4 +-- lib/puppet/parser/functions/is_bool.rb | 4 +-- lib/puppet/parser/functions/is_domain_name.rb | 4 +-- .../parser/functions/is_email_address.rb | 4 +-- lib/puppet/parser/functions/is_float.rb | 4 +-- .../parser/functions/is_function_available.rb | 4 +-- lib/puppet/parser/functions/is_hash.rb | 4 +-- lib/puppet/parser/functions/is_integer.rb | 4 +-- lib/puppet/parser/functions/is_ip_address.rb | 4 +-- .../parser/functions/is_ipv4_address.rb | 4 +-- .../parser/functions/is_ipv6_address.rb | 4 +-- lib/puppet/parser/functions/is_mac_address.rb | 4 +-- lib/puppet/parser/functions/is_numeric.rb | 4 +-- lib/puppet/parser/functions/is_string.rb | 4 +-- lib/puppet/parser/functions/join.rb | 4 +-- .../parser/functions/join_keys_to_values.rb | 4 +-- lib/puppet/parser/functions/keys.rb | 4 +-- .../parser/functions/load_module_metadata.rb | 4 +-- lib/puppet/parser/functions/loadjson.rb | 4 +-- lib/puppet/parser/functions/loadyaml.rb | 4 +-- lib/puppet/parser/functions/lstrip.rb | 4 +-- lib/puppet/parser/functions/max.rb | 4 +-- lib/puppet/parser/functions/member.rb | 4 +-- lib/puppet/parser/functions/merge.rb | 4 +-- lib/puppet/parser/functions/min.rb | 4 +-- lib/puppet/parser/functions/num2bool.rb | 4 +-- lib/puppet/parser/functions/parsejson.rb | 4 +-- lib/puppet/parser/functions/parseyaml.rb | 4 +-- lib/puppet/parser/functions/pick.rb | 4 +-- lib/puppet/parser/functions/pick_default.rb | 4 +-- lib/puppet/parser/functions/prefix.rb | 4 +-- lib/puppet/parser/functions/private.rb | 4 +-- lib/puppet/parser/functions/pry.rb | 4 +-- lib/puppet/parser/functions/range.rb | 4 +-- lib/puppet/parser/functions/regexpescape.rb | 4 +-- lib/puppet/parser/functions/reject.rb | 4 +-- lib/puppet/parser/functions/reverse.rb | 4 +-- lib/puppet/parser/functions/round.rb | 4 +-- lib/puppet/parser/functions/rstrip.rb | 4 +-- lib/puppet/parser/functions/seeded_rand.rb | 4 +-- lib/puppet/parser/functions/shell_escape.rb | 4 +-- lib/puppet/parser/functions/shell_join.rb | 4 +-- lib/puppet/parser/functions/shell_split.rb | 4 +-- lib/puppet/parser/functions/shuffle.rb | 4 +-- lib/puppet/parser/functions/size.rb | 4 +-- lib/puppet/parser/functions/sort.rb | 4 +-- lib/puppet/parser/functions/squeeze.rb | 4 +-- lib/puppet/parser/functions/str2bool.rb | 4 +-- .../parser/functions/str2saltedsha512.rb | 4 +-- lib/puppet/parser/functions/strftime.rb | 4 +-- lib/puppet/parser/functions/strip.rb | 4 +-- lib/puppet/parser/functions/suffix.rb | 4 +-- lib/puppet/parser/functions/swapcase.rb | 4 +-- lib/puppet/parser/functions/time.rb | 4 +-- lib/puppet/parser/functions/to_bytes.rb | 4 +-- lib/puppet/parser/functions/try_get_value.rb | 4 +-- lib/puppet/parser/functions/type.rb | 4 +-- lib/puppet/parser/functions/type3x.rb | 4 +-- lib/puppet/parser/functions/union.rb | 4 +-- lib/puppet/parser/functions/unique.rb | 4 +-- lib/puppet/parser/functions/unix2dos.rb | 4 +-- lib/puppet/parser/functions/upcase.rb | 4 +-- lib/puppet/parser/functions/uriescape.rb | 8 ++--- .../functions/validate_absolute_path.rb | 4 +-- lib/puppet/parser/functions/validate_array.rb | 4 +-- .../parser/functions/validate_augeas.rb | 4 +-- lib/puppet/parser/functions/validate_bool.rb | 4 +-- lib/puppet/parser/functions/validate_cmd.rb | 4 +-- .../parser/functions/validate_domain_name.rb | 4 +-- .../functions/validate_email_address.rb | 4 +-- lib/puppet/parser/functions/validate_hash.rb | 4 +-- .../parser/functions/validate_integer.rb | 4 +-- .../parser/functions/validate_ip_address.rb | 4 +-- .../parser/functions/validate_ipv4_address.rb | 4 +-- .../parser/functions/validate_ipv6_address.rb | 4 +-- .../parser/functions/validate_numeric.rb | 4 +-- lib/puppet/parser/functions/validate_re.rb | 4 +-- .../parser/functions/validate_slength.rb | 4 +-- .../parser/functions/validate_string.rb | 4 +-- .../functions/validate_x509_rsa_key_pair.rb | 4 +-- lib/puppet/parser/functions/values.rb | 4 +-- lib/puppet/parser/functions/values_at.rb | 4 +-- lib/puppet/parser/functions/zip.rb | 4 +-- lib/puppet/provider/file_line/ruby.rb | 12 ++----- lib/puppet/type/anchor.rb | 4 +-- lib/puppet/type/file_line.rb | 4 +-- spec/acceptance/abs_spec.rb | 8 ++--- spec/acceptance/anchor_spec.rb | 4 +-- spec/acceptance/any2array_spec.rb | 12 +++---- spec/acceptance/base64_spec.rb | 4 +-- spec/acceptance/bool2num_spec.rb | 8 ++--- spec/acceptance/capitalize_spec.rb | 8 ++--- spec/acceptance/ceiling_spec.rb | 8 ++--- spec/acceptance/chomp_spec.rb | 4 +-- spec/acceptance/chop_spec.rb | 12 +++---- spec/acceptance/clamp_spec.rb | 8 ++--- spec/acceptance/concat_spec.rb | 16 +++++----- spec/acceptance/count_spec.rb | 8 ++--- spec/acceptance/deep_merge_spec.rb | 4 +-- spec/acceptance/defined_with_params_spec.rb | 4 +-- spec/acceptance/delete_at_spec.rb | 4 +-- spec/acceptance/delete_spec.rb | 4 +-- spec/acceptance/delete_undef_values_spec.rb | 4 +-- spec/acceptance/delete_values_spec.rb | 4 +-- spec/acceptance/difference_spec.rb | 4 +-- spec/acceptance/dirname_spec.rb | 12 +++---- spec/acceptance/downcase_spec.rb | 8 ++--- spec/acceptance/empty_spec.rb | 12 +++---- spec/acceptance/ensure_resource_spec.rb | 8 ++--- spec/acceptance/flatten_spec.rb | 8 ++--- spec/acceptance/floor_spec.rb | 8 ++--- spec/acceptance/fqdn_rand_string_spec.rb | 16 +++++----- spec/acceptance/fqdn_rotate_spec.rb | 16 +++++----- spec/acceptance/get_module_path_spec.rb | 4 +-- spec/acceptance/getparam_spec.rb | 4 +-- spec/acceptance/getvar_spec.rb | 4 +-- spec/acceptance/grep_spec.rb | 4 +-- spec/acceptance/has_interface_with_spec.rb | 12 +++---- spec/acceptance/has_ip_address_spec.rb | 8 ++--- spec/acceptance/has_ip_network_spec.rb | 8 ++--- spec/acceptance/has_key_spec.rb | 8 ++--- spec/acceptance/hash_spec.rb | 4 +-- spec/acceptance/intersection_spec.rb | 4 +-- spec/acceptance/is_a_spec.rb | 8 ++--- spec/acceptance/is_array_spec.rb | 16 +++++----- spec/acceptance/is_bool_spec.rb | 20 ++++++------ spec/acceptance/is_domain_name_spec.rb | 24 +++++++------- spec/acceptance/is_float_spec.rb | 24 +++++++------- spec/acceptance/is_function_available_spec.rb | 16 +++++----- spec/acceptance/is_hash_spec.rb | 16 +++++----- spec/acceptance/is_integer_spec.rb | 24 +++++++------- spec/acceptance/is_ip_address_spec.rb | 20 ++++++------ spec/acceptance/is_ipv4_address_spec.rb | 12 +++---- spec/acceptance/is_ipv6_address_spec.rb | 16 +++++----- spec/acceptance/is_mac_address_spec.rb | 8 ++--- spec/acceptance/is_numeric_spec.rb | 24 +++++++------- spec/acceptance/is_string_spec.rb | 32 +++++++++---------- spec/acceptance/join_keys_to_values_spec.rb | 4 +-- spec/acceptance/join_spec.rb | 4 +-- spec/acceptance/keys_spec.rb | 4 +-- spec/acceptance/loadjson_spec.rb | 12 +++---- spec/acceptance/loadyaml_spec.rb | 12 +++---- spec/acceptance/lstrip_spec.rb | 8 ++--- spec/acceptance/max_spec.rb | 4 +-- spec/acceptance/member_spec.rb | 16 +++++----- spec/acceptance/merge_spec.rb | 4 +-- spec/acceptance/min_spec.rb | 4 +-- spec/acceptance/num2bool_spec.rb | 20 ++++++------ spec/acceptance/parsejson_spec.rb | 16 +++++----- spec/acceptance/parseyaml_spec.rb | 16 +++++----- spec/acceptance/pick_default_spec.rb | 16 +++++----- spec/acceptance/pick_spec.rb | 12 +++---- spec/acceptance/prefix_spec.rb | 12 +++---- spec/acceptance/pw_hash_spec.rb | 8 ++--- spec/acceptance/range_spec.rb | 8 ++--- spec/acceptance/reject_spec.rb | 12 +++---- spec/acceptance/reverse_spec.rb | 4 +-- spec/acceptance/rstrip_spec.rb | 8 ++--- spec/acceptance/shuffle_spec.rb | 8 ++--- spec/acceptance/size_spec.rb | 16 +++++----- spec/acceptance/sort_spec.rb | 8 ++--- spec/acceptance/squeeze_spec.rb | 12 +++---- spec/acceptance/str2bool_spec.rb | 4 +-- spec/acceptance/str2saltedsha512_spec.rb | 4 +-- spec/acceptance/strftime_spec.rb | 4 +-- spec/acceptance/strip_spec.rb | 8 ++--- spec/acceptance/suffix_spec.rb | 12 +++---- spec/acceptance/swapcase_spec.rb | 4 +-- spec/acceptance/time_spec.rb | 8 ++--- spec/acceptance/to_bytes_spec.rb | 4 +-- spec/acceptance/try_get_value_spec.rb | 12 +++---- spec/acceptance/type_spec.rb | 8 ++--- spec/acceptance/union_spec.rb | 4 +-- spec/acceptance/unique_spec.rb | 8 ++--- spec/acceptance/upcase_spec.rb | 8 ++--- spec/acceptance/uriescape_spec.rb | 4 +-- .../acceptance/validate_absolute_path_spec.rb | 4 +-- spec/acceptance/validate_array_spec.rb | 8 ++--- spec/acceptance/validate_augeas_spec.rb | 20 ++++++------ spec/acceptance/validate_bool_spec.rb | 8 ++--- spec/acceptance/validate_cmd_spec.rb | 12 +++---- spec/acceptance/validate_hash_spec.rb | 8 ++--- spec/acceptance/validate_ipv4_address_spec.rb | 8 ++--- spec/acceptance/validate_ipv6_address_spec.rb | 8 ++--- spec/acceptance/validate_re_spec.rb | 16 +++++----- spec/acceptance/validate_slength_spec.rb | 24 +++++++------- spec/acceptance/validate_string_spec.rb | 12 +++---- spec/acceptance/values_at_spec.rb | 24 +++++++------- spec/acceptance/values_spec.rb | 8 ++--- spec/acceptance/zip_spec.rb | 24 +++++++------- spec/functions/basename_spec.rb | 2 +- spec/functions/chomp_spec.rb | 2 +- spec/functions/chop_spec.rb | 2 +- spec/functions/concat_spec.rb | 2 +- spec/functions/deep_merge_spec.rb | 2 +- spec/functions/defined_with_params_spec.rb | 6 ++-- spec/functions/dig44_spec.rb | 6 ++-- spec/functions/dirname_spec.rb | 2 +- spec/functions/dos2unix_spec.rb | 6 ++-- spec/functions/ensure_packages_spec.rb | 10 +++--- spec/functions/ensure_resource_spec.rb | 8 ++--- spec/functions/fqdn_uuid_spec.rb | 4 +-- spec/functions/get_module_path_spec.rb | 4 +-- spec/functions/getvar_spec.rb | 12 +++---- spec/functions/has_interface_with_spec.rb | 4 +-- spec/functions/has_ip_address_spec.rb | 2 +- spec/functions/has_ip_network_spec.rb | 2 +- spec/functions/has_key_spec.rb | 2 +- spec/functions/is_array_spec.rb | 2 +- spec/functions/is_bool_spec.rb | 2 +- spec/functions/is_float_spec.rb | 2 +- spec/functions/is_integer_spec.rb | 2 +- spec/functions/is_mac_address_spec.rb | 2 +- spec/functions/is_numeric_spec.rb | 2 +- spec/functions/is_string_spec.rb | 2 +- spec/functions/join_keys_to_values_spec.rb | 2 +- spec/functions/pick_spec.rb | 2 +- spec/functions/private_spec.rb | 2 +- spec/functions/regexpescape_spec.rb | 2 +- spec/functions/seeded_rand_spec.rb | 2 +- spec/functions/shell_escape_spec.rb | 2 +- spec/functions/shell_join_spec.rb | 2 +- spec/functions/shell_split_spec.rb | 2 +- spec/functions/shuffle_spec.rb | 2 +- spec/functions/sprintf_hash_spec.rb | 4 +-- spec/functions/squeeze_spec.rb | 2 +- spec/functions/try_get_value_spec.rb | 4 +-- spec/functions/unix2dos_spec.rb | 6 ++-- spec/functions/validate_absolute_path_spec.rb | 4 +-- .../validate_x509_rsa_key_pair_spec.rb | 18 +++++------ spec/functions/zip_spec.rb | 2 +- spec/type_aliases/absolute_path_spec.rb | 4 +-- spec/type_aliases/filemode_spec.rb | 2 +- spec/type_aliases/httpsurl_spec.rb | 2 +- spec/type_aliases/httpurl_spec.rb | 2 +- spec/type_aliases/unixpath_spec.rb | 2 +- spec/type_aliases/windowspath_spec.rb | 2 +- spec/unit/facter/facter_dot_d_spec.rb | 4 +-- spec/unit/facter/package_provider_spec.rb | 6 ++-- spec/unit/facter/pe_version_spec.rb | 6 ++-- spec/unit/facter/root_home_spec.rb | 10 +++--- spec/unit/facter/service_provider_spec.rb | 6 ++-- spec/unit/facter/util/puppet_settings_spec.rb | 4 +-- .../puppet/provider/file_line/ruby_spec.rb | 10 +++--- .../provider/file_line/ruby_spec_alter.rb | 4 +-- spec/unit/puppet/type/file_line_spec.rb | 6 ++-- 298 files changed, 925 insertions(+), 936 deletions(-) diff --git a/lib/facter/facter_dot_d.rb b/lib/facter/facter_dot_d.rb index 8f72e2e84..c4ac142e5 100644 --- a/lib/facter/facter_dot_d.rb +++ b/lib/facter/facter_dot_d.rb @@ -23,7 +23,7 @@ def initialize(dir = '/etc/facts.d', cache_file = File.join(Puppet[:libdir], 'fa def entries Dir.entries(@dir).reject { |f| f =~ %r{^\.|\.ttl$} }.sort.map { |f| File.join(@dir, f) } - rescue + rescue # rubocop:disable Lint/RescueWithoutErrorClass [] end @@ -113,14 +113,14 @@ def script_parser(file) def cache_save! cache = load_cache File.open(@cache_file, 'w', 0o600) { |f| f.write(YAML.dump(cache)) } - rescue # rubocop:disable Lint/HandleExceptions - Is meant to be suppressed + rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass end def cache_store(file, data) load_cache @cache[file] = { :data => data, :stored => Time.now.to_i } - rescue # rubocop:disable Lint/HandleExceptions - Is meant to be suppressed + rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass end def cache_lookup(file) @@ -136,7 +136,7 @@ def cache_lookup(file) return cache[file][:data] if ttl == -1 return cache[file][:data] if (now - cache[file][:stored]) <= ttl return nil - rescue + rescue # rubocop:disable Lint/RescueWithoutErrorClass return nil end @@ -144,21 +144,19 @@ def cache_time(file) meta = file + '.ttl' return File.read(meta).chomp.to_i - rescue + rescue # rubocop:disable Lint/RescueWithoutErrorClass return 0 end def load_cache - unless @cache - @cache = if File.exist?(@cache_file) + @cache ||= if File.exist?(@cache_file) YAML.load_file(@cache_file) else {} end - end return @cache - rescue + rescue # rubocop:disable Lint/RescueWithoutErrorClass @cache = {} return @cache end diff --git a/lib/puppet/parser/functions/abs.rb b/lib/puppet/parser/functions/abs.rb index 078d35f48..84bef8c2e 100644 --- a/lib/puppet/parser/functions/abs.rb +++ b/lib/puppet/parser/functions/abs.rb @@ -2,10 +2,10 @@ # abs.rb # module Puppet::Parser::Functions - newfunction(:abs, :type => :rvalue, :doc => <<-EOS + newfunction(:abs, :type => :rvalue, :doc => <<-DOC Returns the absolute value of a number, for example -34.56 becomes 34.56. Takes a single integer and float value as an argument. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/any2array.rb b/lib/puppet/parser/functions/any2array.rb index 0a701db3f..510c2d5bc 100644 --- a/lib/puppet/parser/functions/any2array.rb +++ b/lib/puppet/parser/functions/any2array.rb @@ -2,11 +2,11 @@ # any2array.rb # module Puppet::Parser::Functions - newfunction(:any2array, :type => :rvalue, :doc => <<-EOS + newfunction(:any2array, :type => :rvalue, :doc => <<-DOC This converts any object to an array containing that object. Empty argument lists are converted to an empty array. Arrays are left untouched. Hashes are converted to arrays of alternating keys and values. - EOS + DOC ) do |arguments| if arguments.empty? diff --git a/lib/puppet/parser/functions/any2bool.rb b/lib/puppet/parser/functions/any2bool.rb index 809b9569f..c59924a17 100644 --- a/lib/puppet/parser/functions/any2bool.rb +++ b/lib/puppet/parser/functions/any2bool.rb @@ -2,7 +2,7 @@ # any2bool.rb # module Puppet::Parser::Functions - newfunction(:any2bool, :type => :rvalue, :doc => <<-EOS + newfunction(:any2bool, :type => :rvalue, :doc => <<-DOC This converts 'anything' to a boolean. In practise it does the following: * Strings such as Y,y,1,T,t,TRUE,yes,'true' will return true @@ -11,7 +11,7 @@ module Puppet::Parser::Functions * Number (or a string representation of a number) > 0 will return true, otherwise false * undef will return false * Anything else will return true - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? @@ -33,7 +33,7 @@ module Puppet::Parser::Functions valid_float = begin !!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean - rescue + rescue # rubocop:disable Lint/RescueWithoutErrorClass false end diff --git a/lib/puppet/parser/functions/assert_private.rb b/lib/puppet/parser/functions/assert_private.rb index 9e659f900..9cdebb94e 100644 --- a/lib/puppet/parser/functions/assert_private.rb +++ b/lib/puppet/parser/functions/assert_private.rb @@ -2,10 +2,10 @@ # assert_private.rb # module Puppet::Parser::Functions - newfunction(:assert_private, :doc => <<-'EOS' + newfunction(:assert_private, :doc => <<-DOC Sets the current class or definition as private. Calling the class or definition from outside the current module will fail. - EOS + DOC ) do |args| raise(Puppet::ParseError, "assert_private(): Wrong number of arguments given (#{args.size}}) for 0 or 1)") if args.size > 1 diff --git a/lib/puppet/parser/functions/base64.rb b/lib/puppet/parser/functions/base64.rb index 9c35563e6..484c2f1a4 100644 --- a/lib/puppet/parser/functions/base64.rb +++ b/lib/puppet/parser/functions/base64.rb @@ -1,6 +1,6 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. module Puppet::Parser::Functions - newfunction(:base64, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:base64, :type => :rvalue, :doc => <<-'DOC') do |args| Base64 encode or decode a string based on the command and the string submitted Usage: @@ -13,7 +13,7 @@ module Puppet::Parser::Functions $encodestring = base64('encode', 'thestring', $method) $decodestring = base64('decode', 'dGhlc3RyaW5n', $method) - ENDHEREDOC + DOC require 'base64' diff --git a/lib/puppet/parser/functions/basename.rb b/lib/puppet/parser/functions/basename.rb index cc65efe92..b717fa19c 100644 --- a/lib/puppet/parser/functions/basename.rb +++ b/lib/puppet/parser/functions/basename.rb @@ -2,9 +2,9 @@ # basename.rb # module Puppet::Parser::Functions - newfunction(:basename, :type => :rvalue, :doc => <<-EOS + newfunction(:basename, :type => :rvalue, :doc => <<-DOC Strips directory (and optional suffix) from a filename - EOS + DOC ) do |arguments| raise(Puppet::ParseError, 'basename(): No arguments given') if arguments.empty? diff --git a/lib/puppet/parser/functions/bool2num.rb b/lib/puppet/parser/functions/bool2num.rb index 6ee76f6f4..e8ad96166 100644 --- a/lib/puppet/parser/functions/bool2num.rb +++ b/lib/puppet/parser/functions/bool2num.rb @@ -2,12 +2,12 @@ # bool2num.rb # module Puppet::Parser::Functions - newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS + newfunction(:bool2num, :type => :rvalue, :doc => <<-DOC Converts a boolean to a number. Converts the values: false, f, 0, n, and no to 0 true, t, 1, y, and yes to 1 Requires a single boolean or string as an input. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/bool2str.rb b/lib/puppet/parser/functions/bool2str.rb index 05f35d900..502ab2e0c 100644 --- a/lib/puppet/parser/functions/bool2str.rb +++ b/lib/puppet/parser/functions/bool2str.rb @@ -2,7 +2,7 @@ # bool2str.rb # module Puppet::Parser::Functions - newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS + newfunction(:bool2str, :type => :rvalue, :doc => <<-DOC Converts a boolean to a string using optionally supplied arguments. The optional second and third arguments represent what true and false will be converted to respectively. If only one argument is given, it will be @@ -15,7 +15,7 @@ module Puppet::Parser::Functions bool2str(false, 't', 'f') => 'f' Requires a single boolean as an input. - EOS + DOC ) do |arguments| unless arguments.size == 1 || arguments.size == 3 diff --git a/lib/puppet/parser/functions/camelcase.rb b/lib/puppet/parser/functions/camelcase.rb index e8ff3c5c5..fdc54a23c 100644 --- a/lib/puppet/parser/functions/camelcase.rb +++ b/lib/puppet/parser/functions/camelcase.rb @@ -3,9 +3,9 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:camelcase, :type => :rvalue, :doc => <<-EOS + newfunction(:camelcase, :type => :rvalue, :doc => <<-DOC Converts the case of a string or all strings in an array to camel case. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "camelcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/capitalize.rb b/lib/puppet/parser/functions/capitalize.rb index 57a86b7b8..7d7703fe3 100644 --- a/lib/puppet/parser/functions/capitalize.rb +++ b/lib/puppet/parser/functions/capitalize.rb @@ -3,10 +3,10 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS + newfunction(:capitalize, :type => :rvalue, :doc => <<-DOC Capitalizes the first letter of a string or array of strings. Requires either a single string or an array as an input. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "capitalize(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/ceiling.rb b/lib/puppet/parser/functions/ceiling.rb index 3fd3bb022..d0323a884 100644 --- a/lib/puppet/parser/functions/ceiling.rb +++ b/lib/puppet/parser/functions/ceiling.rb @@ -2,10 +2,10 @@ # ceiling.rb # module Puppet::Parser::Functions - newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS + newfunction(:ceiling, :type => :rvalue, :doc => <<-DOC Returns the smallest integer greater or equal to the argument. Takes a single numeric value as an argument. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "ceiling(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/chomp.rb b/lib/puppet/parser/functions/chomp.rb index a37718713..0e9cd6dc4 100644 --- a/lib/puppet/parser/functions/chomp.rb +++ b/lib/puppet/parser/functions/chomp.rb @@ -2,11 +2,11 @@ # chomp.rb # module Puppet::Parser::Functions - newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS' + newfunction(:chomp, :type => :rvalue, :doc => <<-DOC Removes the record separator from the end of a string or an array of strings, for example `hello\n` becomes `hello`. Requires a single string or array as an input. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "chomp(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/chop.rb b/lib/puppet/parser/functions/chop.rb index e01e17838..80e896481 100644 --- a/lib/puppet/parser/functions/chop.rb +++ b/lib/puppet/parser/functions/chop.rb @@ -2,13 +2,13 @@ # chop.rb # module Puppet::Parser::Functions - newfunction(:chop, :type => :rvalue, :doc => <<-'EOS' + newfunction(:chop, :type => :rvalue, :doc => <<-DOC Returns a new string with the last character removed. If the string ends with `\r\n`, both characters are removed. Applying chop to an empty string returns an empty string. If you wish to merely remove record separators then you should use the `chomp` function. Requires a string or array of strings as input. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "chop(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/clamp.rb b/lib/puppet/parser/functions/clamp.rb index 3527a5c35..0aea5112f 100644 --- a/lib/puppet/parser/functions/clamp.rb +++ b/lib/puppet/parser/functions/clamp.rb @@ -2,9 +2,9 @@ # clamp.rb # module Puppet::Parser::Functions - newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS + newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-DOC Clamps value to a range. - EOS + DOC ) do |args| args.flatten! diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb index 435a88e9e..9a83ec118 100644 --- a/lib/puppet/parser/functions/concat.rb +++ b/lib/puppet/parser/functions/concat.rb @@ -2,7 +2,7 @@ # concat.rb # module Puppet::Parser::Functions - newfunction(:concat, :type => :rvalue, :doc => <<-EOS + newfunction(:concat, :type => :rvalue, :doc => <<-DOC Appends the contents of multiple arrays into array 1. *Example:* @@ -12,7 +12,7 @@ module Puppet::Parser::Functions Would result in: ['1','2','3','4','5','6','7','8','9'] - EOS + DOC ) do |arguments| # Check that more than 2 arguments have been given ... diff --git a/lib/puppet/parser/functions/convert_base.rb b/lib/puppet/parser/functions/convert_base.rb index 8a1311dff..6d17f85b6 100644 --- a/lib/puppet/parser/functions/convert_base.rb +++ b/lib/puppet/parser/functions/convert_base.rb @@ -2,7 +2,7 @@ # convert_base.rb # module Puppet::Parser::Functions - newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:convert_base, :type => :rvalue, :arity => 2, :doc => <<-'DOC') do |args| Converts a given integer or base 10 string representing an integer to a specified base, as a string. Usage: @@ -10,7 +10,7 @@ module Puppet::Parser::Functions $binary_repr = convert_base(5, 2) # $binary_repr is now set to "101" $hex_repr = convert_base("254", "16") # $hex_repr is now set to "fe" - ENDHEREDOC + DOC raise Puppet::ParseError, 'convert_base(): First argument must be either a string or an integer' unless args[0].is_a?(Integer) || args[0].is_a?(String) raise Puppet::ParseError, 'convert_base(): Second argument must be either a string or an integer' unless args[1].is_a?(Integer) || args[1].is_a?(String) diff --git a/lib/puppet/parser/functions/count.rb b/lib/puppet/parser/functions/count.rb index abbcecb2a..f5ac8c3bd 100644 --- a/lib/puppet/parser/functions/count.rb +++ b/lib/puppet/parser/functions/count.rb @@ -2,11 +2,11 @@ # count.rb # module Puppet::Parser::Functions - newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS + newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-DOC Takes an array as first argument and an optional second argument. Count the number of elements in array that matches second argument. If called with only an array it counts the number of elements that are not nil/undef. - EOS + DOC ) do |args| if args.size > 2 diff --git a/lib/puppet/parser/functions/deep_merge.rb b/lib/puppet/parser/functions/deep_merge.rb index 267ef4b47..dd70c6178 100644 --- a/lib/puppet/parser/functions/deep_merge.rb +++ b/lib/puppet/parser/functions/deep_merge.rb @@ -2,7 +2,7 @@ # deep_merge.rb # module Puppet::Parser::Functions - newfunction(:deep_merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:deep_merge, :type => :rvalue, :doc => <<-'DOC') do |args| Recursively merges two or more hashes together and returns the resulting hash. For example: @@ -16,7 +16,7 @@ module Puppet::Parser::Functions When there is a duplicate key that is a hash, they are recursively merged. When there is a duplicate key that is not a hash, the key in the rightmost hash will "win." - ENDHEREDOC + DOC if args.length < 2 raise Puppet::ParseError, "deep_merge(): wrong number of arguments (#{args.length}; must be at least 2)" diff --git a/lib/puppet/parser/functions/defined_with_params.rb b/lib/puppet/parser/functions/defined_with_params.rb index d7c41c2d4..138330808 100644 --- a/lib/puppet/parser/functions/defined_with_params.rb +++ b/lib/puppet/parser/functions/defined_with_params.rb @@ -3,7 +3,7 @@ Puppet::Parser::Functions.newfunction(:defined_with_params, :type => :rvalue, - :doc => <<-'ENDOFDOC' + :doc => <<-'DOC' Takes a resource reference and an optional hash of attributes. Returns true if a resource with the specified attributes has already been added @@ -16,7 +16,7 @@ if ! defined_with_params(User[dan], {'ensure' => 'present' }) { user { 'dan': ensure => present, } } -ENDOFDOC +DOC ) do |vals| reference, params = vals raise(ArgumentError, 'Must specify a reference') unless reference diff --git a/lib/puppet/parser/functions/delete.rb b/lib/puppet/parser/functions/delete.rb index ca3b17cd3..f83ff16e9 100644 --- a/lib/puppet/parser/functions/delete.rb +++ b/lib/puppet/parser/functions/delete.rb @@ -2,7 +2,7 @@ # delete.rb # module Puppet::Parser::Functions - newfunction(:delete, :type => :rvalue, :doc => <<-EOS + newfunction(:delete, :type => :rvalue, :doc => <<-DOC Deletes all instances of a given element from an array, substring from a string, or key from a hash. @@ -19,7 +19,7 @@ module Puppet::Parser::Functions delete('abracadabra', 'bra') Would return: 'acada' - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "delete(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2 diff --git a/lib/puppet/parser/functions/delete_at.rb b/lib/puppet/parser/functions/delete_at.rb index c96c45f8d..e40ad2648 100644 --- a/lib/puppet/parser/functions/delete_at.rb +++ b/lib/puppet/parser/functions/delete_at.rb @@ -2,7 +2,7 @@ # delete_at.rb # module Puppet::Parser::Functions - newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_at, :type => :rvalue, :doc => <<-DOC Deletes a determined indexed value from an array. *Examples:* @@ -10,7 +10,7 @@ module Puppet::Parser::Functions delete_at(['a','b','c'], 1) Would return: ['a','c'] - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "delete_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 diff --git a/lib/puppet/parser/functions/delete_regex.rb b/lib/puppet/parser/functions/delete_regex.rb index 19f1cd6ac..64cad9c9f 100644 --- a/lib/puppet/parser/functions/delete_regex.rb +++ b/lib/puppet/parser/functions/delete_regex.rb @@ -3,7 +3,7 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:delete_regex, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_regex, :type => :rvalue, :doc => <<-DOC deletes all instances of a given element that match a regular expression from an array or key from a hash. Multiple regular expressions are assumed to be matched as an OR. @@ -22,7 +22,7 @@ module Puppet::Parser::Functions delete_regex({'a'=>1,'b'=>2,'c'=>3}, '^a$') Would return: {'b'=>2,'c'=>3} - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "delete_regex(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2 diff --git a/lib/puppet/parser/functions/delete_undef_values.rb b/lib/puppet/parser/functions/delete_undef_values.rb index 8a1841e5c..af2dbc783 100644 --- a/lib/puppet/parser/functions/delete_undef_values.rb +++ b/lib/puppet/parser/functions/delete_undef_values.rb @@ -2,7 +2,7 @@ # delete_undef_values.rb # module Puppet::Parser::Functions - newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_undef_values, :type => :rvalue, :doc => <<-DOC Returns a copy of input hash or array with all undefs deleted. *Examples:* @@ -15,7 +15,7 @@ module Puppet::Parser::Functions Would return: ['A','',false] - EOS + DOC ) do |args| raise(Puppet::ParseError, "delete_undef_values(): Wrong number of arguments given (#{args.size})") if args.empty? diff --git a/lib/puppet/parser/functions/delete_values.rb b/lib/puppet/parser/functions/delete_values.rb index 4544ba740..1192766de 100644 --- a/lib/puppet/parser/functions/delete_values.rb +++ b/lib/puppet/parser/functions/delete_values.rb @@ -2,7 +2,7 @@ # delete_values.rb # module Puppet::Parser::Functions - newfunction(:delete_values, :type => :rvalue, :doc => <<-EOS + newfunction(:delete_values, :type => :rvalue, :doc => <<-DOC Deletes all instances of a given value from a hash. *Examples:* @@ -11,7 +11,7 @@ module Puppet::Parser::Functions Would return: {'a'=>'A','c'=>'C','B'=>'D'} - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "delete_values(): Wrong number of arguments given (#{arguments.size} of 2)") if arguments.size != 2 diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index b1ae0e76a..01f0deb1c 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -2,9 +2,9 @@ # deprecation.rb # module Puppet::Parser::Functions - newfunction(:deprecation, :doc => <<-EOS + newfunction(:deprecation, :doc => <<-DOC Function to print deprecation warnings (this is the 3.X version of it), The uniqueness key - can appear once. The msg is the message text including any positional information that is formatted by the user/caller of the method.). -EOS +DOC ) do |arguments| raise(Puppet::ParseError, "deprecation: Wrong number of arguments given (#{arguments.size} for 2)") unless arguments.size == 2 diff --git a/lib/puppet/parser/functions/difference.rb b/lib/puppet/parser/functions/difference.rb index a7510415b..cfaebc9d4 100644 --- a/lib/puppet/parser/functions/difference.rb +++ b/lib/puppet/parser/functions/difference.rb @@ -2,7 +2,7 @@ # difference.rb # module Puppet::Parser::Functions - newfunction(:difference, :type => :rvalue, :doc => <<-EOS + newfunction(:difference, :type => :rvalue, :doc => <<-DOC This function returns the difference between two arrays. The returned array is a copy of the original array, removing any items that also appear in the second array. @@ -12,7 +12,7 @@ module Puppet::Parser::Functions difference(["a","b","c"],["b","c","d"]) Would return: ["a"] - EOS + DOC ) do |arguments| # Two arguments are required diff --git a/lib/puppet/parser/functions/dig.rb b/lib/puppet/parser/functions/dig.rb index c9cf5fc26..75e83aa7e 100644 --- a/lib/puppet/parser/functions/dig.rb +++ b/lib/puppet/parser/functions/dig.rb @@ -2,9 +2,9 @@ # dig.rb # module Puppet::Parser::Functions - newfunction(:dig, :type => :rvalue, :doc => <<-EOS + newfunction(:dig, :type => :rvalue, :doc => <<-DOC DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version. - EOS + DOC ) do |arguments| warning('dig() DEPRECATED: This function has been replaced in Puppet 4.5.0, please use dig44() for backwards compatibility or use the new version.') unless Puppet::Parser::Functions.autoloader.loaded?(:dig44) diff --git a/lib/puppet/parser/functions/dig44.rb b/lib/puppet/parser/functions/dig44.rb index 9eaa70f94..e3fb8a39f 100644 --- a/lib/puppet/parser/functions/dig44.rb +++ b/lib/puppet/parser/functions/dig44.rb @@ -6,7 +6,7 @@ module Puppet::Parser::Functions :dig44, :type => :rvalue, :arity => -2, - :doc => <<-eos + :doc => <<-DOC DEPRECATED: This function has been replaced in puppet 4.5.0. Looks up into a complex structure of arrays and hashes and returns a value @@ -38,7 +38,7 @@ module Puppet::Parser::Functions In addition to the required "key" argument, the function accepts a default argument. It will be returned if no value was found or a path component is missing. And the fourth argument can set a variable path separator. - eos + DOC ) do |arguments| # Two arguments are required raise(Puppet::ParseError, "dig44(): Wrong number of arguments given (#{arguments.size} for at least 2)") if arguments.size < 2 @@ -53,7 +53,7 @@ module Puppet::Parser::Functions if structure.is_a? Array begin key = Integer key - rescue + rescue # rubocop:disable Lint/RescueWithoutErrorClass break end end diff --git a/lib/puppet/parser/functions/dirname.rb b/lib/puppet/parser/functions/dirname.rb index ec95e9d49..a24328794 100644 --- a/lib/puppet/parser/functions/dirname.rb +++ b/lib/puppet/parser/functions/dirname.rb @@ -2,9 +2,9 @@ # dirname.rb # module Puppet::Parser::Functions - newfunction(:dirname, :type => :rvalue, :doc => <<-EOS + newfunction(:dirname, :type => :rvalue, :doc => <<-DOC Returns the dirname of a path. - EOS + DOC ) do |arguments| if arguments.empty? diff --git a/lib/puppet/parser/functions/dos2unix.rb b/lib/puppet/parser/functions/dos2unix.rb index 3ee0198a2..32722ba50 100644 --- a/lib/puppet/parser/functions/dos2unix.rb +++ b/lib/puppet/parser/functions/dos2unix.rb @@ -1,9 +1,9 @@ # Custom Puppet function to convert dos to unix format module Puppet::Parser::Functions - newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-EOS + newfunction(:dos2unix, :type => :rvalue, :arity => 1, :doc => <<-DOC Returns the Unix version of the given string. Takes a single string argument. - EOS + DOC ) do |arguments| unless arguments[0].is_a?(String) diff --git a/lib/puppet/parser/functions/downcase.rb b/lib/puppet/parser/functions/downcase.rb index 1367c7245..1661e562c 100644 --- a/lib/puppet/parser/functions/downcase.rb +++ b/lib/puppet/parser/functions/downcase.rb @@ -3,9 +3,9 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:downcase, :type => :rvalue, :doc => <<-EOS + newfunction(:downcase, :type => :rvalue, :doc => <<-DOC Converts the case of a string or all strings in an array to lower case. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "downcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/empty.rb b/lib/puppet/parser/functions/empty.rb index 9fe46c112..79c43d0b1 100644 --- a/lib/puppet/parser/functions/empty.rb +++ b/lib/puppet/parser/functions/empty.rb @@ -2,9 +2,9 @@ # empty.rb # module Puppet::Parser::Functions - newfunction(:empty, :type => :rvalue, :doc => <<-EOS + newfunction(:empty, :type => :rvalue, :doc => <<-DOC Returns true if the variable is empty. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/enclose_ipv6.rb b/lib/puppet/parser/functions/enclose_ipv6.rb index 5a633c81b..f412b018b 100644 --- a/lib/puppet/parser/functions/enclose_ipv6.rb +++ b/lib/puppet/parser/functions/enclose_ipv6.rb @@ -2,9 +2,9 @@ # enclose_ipv6.rb # module Puppet::Parser::Functions - newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-EOS + newfunction(:enclose_ipv6, :type => :rvalue, :doc => <<-DOC Takes an array of ip addresses and encloses the ipv6 addresses with square brackets. - EOS + DOC ) do |arguments| require 'ipaddr' diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index f3fd7bb71..e1c4f6594 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -2,11 +2,11 @@ # ensure_packages.rb # module Puppet::Parser::Functions - newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS + newfunction(:ensure_packages, :type => :statement, :doc => <<-DOC Takes a list of packages and only installs them if they don't already exist. It optionally takes a hash as a second parameter that will be passed as the third argument to the ensure_resource() function. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments given (#{arguments.size} for 1 or 2)") if arguments.size > 2 || arguments.empty? diff --git a/lib/puppet/parser/functions/ensure_resource.rb b/lib/puppet/parser/functions/ensure_resource.rb index 8ba6d7ca0..d28ed9db7 100644 --- a/lib/puppet/parser/functions/ensure_resource.rb +++ b/lib/puppet/parser/functions/ensure_resource.rb @@ -3,7 +3,7 @@ Puppet::Parser::Functions.newfunction(:ensure_resource, :type => :statement, - :doc => <<-'ENDOFDOC' + :doc => <<-'DOC' Takes a resource type, title, and a list of attributes that describe a resource. @@ -24,7 +24,7 @@ ensure_resource('user', ['dan','alex'], {'ensure' => 'present'}) -ENDOFDOC +DOC ) do |vals| type, title, params = vals raise(ArgumentError, 'Must specify a type') unless type diff --git a/lib/puppet/parser/functions/ensure_resources.rb b/lib/puppet/parser/functions/ensure_resources.rb index 6b0ee5499..642247c9c 100644 --- a/lib/puppet/parser/functions/ensure_resources.rb +++ b/lib/puppet/parser/functions/ensure_resources.rb @@ -2,7 +2,7 @@ Puppet::Parser::Functions.newfunction(:ensure_resources, :type => :statement, - :doc => <<-'ENDOFDOC' + :doc => <<-'DOC' Takes a resource type, title (only hash), and a list of attributes that describe a resource. @@ -27,7 +27,7 @@ Call: ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'}) -ENDOFDOC +DOC ) do |vals| type, title, params = vals raise(ArgumentError, 'Must specify a type') unless type diff --git a/lib/puppet/parser/functions/flatten.rb b/lib/puppet/parser/functions/flatten.rb index d2e1912ed..15970dfa5 100644 --- a/lib/puppet/parser/functions/flatten.rb +++ b/lib/puppet/parser/functions/flatten.rb @@ -2,7 +2,7 @@ # flatten.rb # module Puppet::Parser::Functions - newfunction(:flatten, :type => :rvalue, :doc => <<-EOS + newfunction(:flatten, :type => :rvalue, :doc => <<-DOC This function flattens any deeply nested arrays and returns a single flat array as a result. @@ -11,7 +11,7 @@ module Puppet::Parser::Functions flatten(['a', ['b', ['c']]]) Would return: ['a','b','c'] - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/floor.rb b/lib/puppet/parser/functions/floor.rb index b545011bf..9fcb048aa 100644 --- a/lib/puppet/parser/functions/floor.rb +++ b/lib/puppet/parser/functions/floor.rb @@ -2,10 +2,10 @@ # floor.rb # module Puppet::Parser::Functions - newfunction(:floor, :type => :rvalue, :doc => <<-EOS + newfunction(:floor, :type => :rvalue, :doc => <<-DOC Returns the largest integer less or equal to the argument. Takes a single numeric value as an argument. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "floor(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/fqdn_uuid.rb b/lib/puppet/parser/functions/fqdn_uuid.rb index da9f7a982..5080e8ebf 100644 --- a/lib/puppet/parser/functions/fqdn_uuid.rb +++ b/lib/puppet/parser/functions/fqdn_uuid.rb @@ -3,7 +3,7 @@ # fqdn_uuid.rb # module Puppet::Parser::Functions - newfunction(:fqdn_uuid, :type => :rvalue, :doc => <<-END) do |args| + newfunction(:fqdn_uuid, :type => :rvalue, :doc => <<-DOC) do |args| Creates a UUID based on a given string, assumed to be the FQDN For example, to generate a UUID based on the FQDN of a system: @@ -32,8 +32,7 @@ module Puppet::Parser::Functions No verification is present at the moment as whether the domain name given is in fact a correct fully-qualified domain name. Therefore any arbitrary string and/or alpha-numeric value can subside for a domain name. - EOS - END + DOC raise(ArgumentError, 'fqdn_uuid: No arguments given') if args.empty? raise(ArgumentError, "fqdn_uuid: Too many arguments given (#{args.length})") unless args.length == 1 diff --git a/lib/puppet/parser/functions/get_module_path.rb b/lib/puppet/parser/functions/get_module_path.rb index eac8906a1..3a95b711e 100644 --- a/lib/puppet/parser/functions/get_module_path.rb +++ b/lib/puppet/parser/functions/get_module_path.rb @@ -2,13 +2,13 @@ # get_module_path.rb # module Puppet::Parser::Functions - newfunction(:get_module_path, :type => :rvalue, :doc => <<-EOT + newfunction(:get_module_path, :type => :rvalue, :doc => <<-DOC Returns the absolute path of the specified module for the current environment. Example: $module_path = get_module_path('stdlib') - EOT + DOC ) do |args| raise(Puppet::ParseError, 'get_module_path(): Wrong number of arguments, expects one') unless args.size == 1 module_path = Puppet::Module.find(args[0], compiler.environment.to_s) diff --git a/lib/puppet/parser/functions/getparam.rb b/lib/puppet/parser/functions/getparam.rb index 62399250c..d73650bd1 100644 --- a/lib/puppet/parser/functions/getparam.rb +++ b/lib/puppet/parser/functions/getparam.rb @@ -3,7 +3,7 @@ Puppet::Parser::Functions.newfunction(:getparam, :type => :rvalue, - :doc => <<-'ENDOFDOC' + :doc => <<-'DOC' Takes a resource reference and name of the parameter and returns value of resource's parameter. @@ -19,7 +19,7 @@ getparam(Example_resource["example_resource_instance"], "param") Would return: param_value - ENDOFDOC + DOC ) do |vals| reference, param = vals raise(ArgumentError, 'Must specify a reference') unless reference diff --git a/lib/puppet/parser/functions/getvar.rb b/lib/puppet/parser/functions/getvar.rb index 8c69c36cf..f4644677e 100644 --- a/lib/puppet/parser/functions/getvar.rb +++ b/lib/puppet/parser/functions/getvar.rb @@ -2,7 +2,7 @@ # getvar.rb # module Puppet::Parser::Functions - newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:getvar, :type => :rvalue, :doc => <<-'DOC') do |args| Lookup a variable in a remote namespace. For example: @@ -15,7 +15,7 @@ module Puppet::Parser::Functions $datalocation = 'site::data' $bar = getvar("${datalocation}::bar") # Equivalent to $bar = $site::data::bar - ENDHEREDOC + DOC unless args.length == 1 raise Puppet::ParseError, "getvar(): wrong number of arguments (#{args.length}; must be 1)" diff --git a/lib/puppet/parser/functions/glob.rb b/lib/puppet/parser/functions/glob.rb index c19195a65..e9d35b282 100644 --- a/lib/puppet/parser/functions/glob.rb +++ b/lib/puppet/parser/functions/glob.rb @@ -2,10 +2,10 @@ # glob.rb # module Puppet::Parser::Functions - newfunction(:glob, :type => :rvalue, :doc => <<-'EOS' + newfunction(:glob, :type => :rvalue, :doc => <<-'DOC' Returns an Array of file entries of a directory or an Array of directories. Uses same patterns as Dir#glob - EOS + DOC ) do |arguments| unless arguments.size == 1 diff --git a/lib/puppet/parser/functions/grep.rb b/lib/puppet/parser/functions/grep.rb index 915592efe..030c14ae1 100644 --- a/lib/puppet/parser/functions/grep.rb +++ b/lib/puppet/parser/functions/grep.rb @@ -2,7 +2,7 @@ # grep.rb # module Puppet::Parser::Functions - newfunction(:grep, :type => :rvalue, :doc => <<-EOS + newfunction(:grep, :type => :rvalue, :doc => <<-DOC This function searches through an array and returns any elements that match the provided regular expression. @@ -13,7 +13,7 @@ module Puppet::Parser::Functions Would return: ['aaa','aaaddd'] - EOS + DOC ) do |arguments| if arguments.size != 2 diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb index babe1fce4..44005d0a0 100644 --- a/lib/puppet/parser/functions/has_interface_with.rb +++ b/lib/puppet/parser/functions/has_interface_with.rb @@ -2,7 +2,7 @@ # has_interface_with # module Puppet::Parser::Functions - newfunction(:has_interface_with, :type => :rvalue, :doc => <<-EOS + newfunction(:has_interface_with, :type => :rvalue, :doc => <<-DOC Returns boolean based on kind and value: * macaddress * netmask @@ -15,7 +15,7 @@ module Puppet::Parser::Functions If no "kind" is given, then the presence of the interface is checked: has_interface_with("lo") => true - EOS + DOC ) do |args| raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments given (#{args.size} for 1 or 2)") if args.empty? || args.size > 2 diff --git a/lib/puppet/parser/functions/has_ip_address.rb b/lib/puppet/parser/functions/has_ip_address.rb index 303dcd940..5f14ee203 100644 --- a/lib/puppet/parser/functions/has_ip_address.rb +++ b/lib/puppet/parser/functions/has_ip_address.rb @@ -2,12 +2,12 @@ # has_ip_address # module Puppet::Parser::Functions - newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS + newfunction(:has_ip_address, :type => :rvalue, :doc => <<-DOC Returns true if the client has the requested IP address on some interface. This function iterates through the 'interfaces' fact and checks the 'ipaddress_IFACE' facts, performing a simple string comparison. - EOS + DOC ) do |args| raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1 diff --git a/lib/puppet/parser/functions/has_ip_network.rb b/lib/puppet/parser/functions/has_ip_network.rb index 2ee594527..65f278900 100644 --- a/lib/puppet/parser/functions/has_ip_network.rb +++ b/lib/puppet/parser/functions/has_ip_network.rb @@ -2,12 +2,12 @@ # has_ip_network # module Puppet::Parser::Functions - newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS + newfunction(:has_ip_network, :type => :rvalue, :doc => <<-DOC Returns true if the client has an IP address within the requested network. This function iterates through the 'interfaces' fact and checks the 'network_IFACE' facts, performing a simple string comparision. - EOS + DOC ) do |args| raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1 diff --git a/lib/puppet/parser/functions/has_key.rb b/lib/puppet/parser/functions/has_key.rb index 5597b867e..53b8c74e9 100644 --- a/lib/puppet/parser/functions/has_key.rb +++ b/lib/puppet/parser/functions/has_key.rb @@ -2,7 +2,7 @@ # has_key.rb # module Puppet::Parser::Functions - newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:has_key, :type => :rvalue, :doc => <<-'DOC') do |args| Determine if a hash has a certain key value. Example: @@ -15,7 +15,7 @@ module Puppet::Parser::Functions notice('this will be printed') } - ENDHEREDOC + DOC unless args.length == 2 raise Puppet::ParseError, "has_key(): wrong number of arguments (#{args.length}; must be 2)" diff --git a/lib/puppet/parser/functions/hash.rb b/lib/puppet/parser/functions/hash.rb index 04340be88..f6644dbb1 100644 --- a/lib/puppet/parser/functions/hash.rb +++ b/lib/puppet/parser/functions/hash.rb @@ -2,7 +2,7 @@ # hash.rb # module Puppet::Parser::Functions - newfunction(:hash, :type => :rvalue, :doc => <<-EOS + newfunction(:hash, :type => :rvalue, :doc => <<-DOC This function converts an array into a hash. *Examples:* @@ -10,7 +10,7 @@ module Puppet::Parser::Functions hash(['a',1,'b',2,'c',3]) Would return: {'a'=>1,'b'=>2,'c'=>3} - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/intersection.rb b/lib/puppet/parser/functions/intersection.rb index 1d80f5eed..0c16722ee 100644 --- a/lib/puppet/parser/functions/intersection.rb +++ b/lib/puppet/parser/functions/intersection.rb @@ -2,14 +2,14 @@ # intersection.rb # module Puppet::Parser::Functions - newfunction(:intersection, :type => :rvalue, :doc => <<-EOS + newfunction(:intersection, :type => :rvalue, :doc => <<-DOC This function returns an array of the intersection of two. *Examples:* intersection(["a","b","c"],["b","c","d"]) # returns ["b","c"] intersection(["a","b","c"],[1,2,3,4]) # returns [] (true, when evaluated as a Boolean) - EOS + DOC ) do |arguments| # Two arguments are required diff --git a/lib/puppet/parser/functions/is_absolute_path.rb b/lib/puppet/parser/functions/is_absolute_path.rb index 43d5308da..06e9465d3 100644 --- a/lib/puppet/parser/functions/is_absolute_path.rb +++ b/lib/puppet/parser/functions/is_absolute_path.rb @@ -2,7 +2,7 @@ # is_absolute_path.rb # module Puppet::Parser::Functions - newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:is_absolute_path, :type => :rvalue, :arity => 1, :doc => <<-'DOC') do |args| Returns boolean true if the string represents an absolute path in the filesystem. This function works for windows and unix style paths. @@ -25,7 +25,7 @@ module Puppet::Parser::Functions $undefined = undef is_absolute_path($undefined) - ENDHEREDOC + DOC function_deprecation([:is_absolute_path, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Absolute_path. There is further documentation for validate_legacy function in the README.']) require 'puppet/util' diff --git a/lib/puppet/parser/functions/is_array.rb b/lib/puppet/parser/functions/is_array.rb index 47643c426..620f4f796 100644 --- a/lib/puppet/parser/functions/is_array.rb +++ b/lib/puppet/parser/functions/is_array.rb @@ -2,9 +2,9 @@ # is_array.rb # module Puppet::Parser::Functions - newfunction(:is_array, :type => :rvalue, :doc => <<-EOS + newfunction(:is_array, :type => :rvalue, :doc => <<-DOC Returns true if the variable passed to this function is an array. - EOS + DOC ) do |arguments| function_deprecation([:is_array, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/is_bool.rb b/lib/puppet/parser/functions/is_bool.rb index f00f4102a..d0e002616 100644 --- a/lib/puppet/parser/functions/is_bool.rb +++ b/lib/puppet/parser/functions/is_bool.rb @@ -2,9 +2,9 @@ # is_bool.rb # module Puppet::Parser::Functions - newfunction(:is_bool, :type => :rvalue, :doc => <<-EOS + newfunction(:is_bool, :type => :rvalue, :doc => <<-DOC Returns true if the variable passed to this function is a boolean. - EOS + DOC ) do |arguments| function_deprecation([:is_bool, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/is_domain_name.rb b/lib/puppet/parser/functions/is_domain_name.rb index 82d5e9c15..d80689a68 100644 --- a/lib/puppet/parser/functions/is_domain_name.rb +++ b/lib/puppet/parser/functions/is_domain_name.rb @@ -2,9 +2,9 @@ # is_domain_name.rb # module Puppet::Parser::Functions - newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS + newfunction(:is_domain_name, :type => :rvalue, :doc => <<-DOC Returns true if the string passed to this function is a syntactically correct domain name. - EOS + DOC ) do |arguments| if arguments.size != 1 diff --git a/lib/puppet/parser/functions/is_email_address.rb b/lib/puppet/parser/functions/is_email_address.rb index 3225e93be..f656468eb 100644 --- a/lib/puppet/parser/functions/is_email_address.rb +++ b/lib/puppet/parser/functions/is_email_address.rb @@ -2,9 +2,9 @@ # is_email_address.rb # module Puppet::Parser::Functions - newfunction(:is_email_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_email_address, :type => :rvalue, :doc => <<-DOC Returns true if the string passed to this function is a valid email address. - EOS + DOC ) do |arguments| if arguments.size != 1 raise(Puppet::ParseError, "is_email_address(): Wrong number of arguments given #{arguments.size} for 1") diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index c80a04eae..89994d29d 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.rb @@ -2,9 +2,9 @@ # is_float.rb # module Puppet::Parser::Functions - newfunction(:is_float, :type => :rvalue, :doc => <<-EOS + newfunction(:is_float, :type => :rvalue, :doc => <<-DOC Returns true if the variable passed to this function is a float. - EOS + DOC ) do |arguments| function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/is_function_available.rb b/lib/puppet/parser/functions/is_function_available.rb index f47ff8be8..e02aa536d 100644 --- a/lib/puppet/parser/functions/is_function_available.rb +++ b/lib/puppet/parser/functions/is_function_available.rb @@ -2,11 +2,11 @@ # is_function_available.rb # module Puppet::Parser::Functions - newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS + newfunction(:is_function_available, :type => :rvalue, :doc => <<-DOC This function accepts a string as an argument, determines whether the Puppet runtime has access to a function by that name. It returns a true if the function exists, false if not. - EOS + DOC ) do |arguments| if arguments.size != 1 diff --git a/lib/puppet/parser/functions/is_hash.rb b/lib/puppet/parser/functions/is_hash.rb index 9e7450515..dc036530c 100644 --- a/lib/puppet/parser/functions/is_hash.rb +++ b/lib/puppet/parser/functions/is_hash.rb @@ -2,9 +2,9 @@ # is_hash.rb # module Puppet::Parser::Functions - newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS + newfunction(:is_hash, :type => :rvalue, :doc => <<-DOC Returns true if the variable passed to this function is a hash. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "is_hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/is_integer.rb b/lib/puppet/parser/functions/is_integer.rb index fd767956e..7444cace7 100644 --- a/lib/puppet/parser/functions/is_integer.rb +++ b/lib/puppet/parser/functions/is_integer.rb @@ -2,14 +2,14 @@ # is_integer.rb # module Puppet::Parser::Functions - newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS + newfunction(:is_integer, :type => :rvalue, :doc => <<-DOC Returns true if the variable passed to this function is an Integer or a decimal (base 10) integer in String form. The string may start with a '-' (minus). A value of '0' is allowed, but a leading '0' digit may not be followed by other digits as this indicates that the value is octal (base 8). If given any other argument `false` is returned. - EOS + DOC ) do |arguments| function_deprecation([:is_integer, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/is_ip_address.rb b/lib/puppet/parser/functions/is_ip_address.rb index 064fea42d..6ce993a3c 100644 --- a/lib/puppet/parser/functions/is_ip_address.rb +++ b/lib/puppet/parser/functions/is_ip_address.rb @@ -2,9 +2,9 @@ # is_ip_address.rb # module Puppet::Parser::Functions - newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_ip_address, :type => :rvalue, :doc => <<-DOC Returns true if the string passed to this function is a valid IP address. - EOS + DOC ) do |arguments| require 'ipaddr' diff --git a/lib/puppet/parser/functions/is_ipv4_address.rb b/lib/puppet/parser/functions/is_ipv4_address.rb index 8d93f1492..7f2241b74 100644 --- a/lib/puppet/parser/functions/is_ipv4_address.rb +++ b/lib/puppet/parser/functions/is_ipv4_address.rb @@ -2,9 +2,9 @@ # is_ipv4_address.rb # module Puppet::Parser::Functions - newfunction(:is_ipv4_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_ipv4_address, :type => :rvalue, :doc => <<-DOC Returns true if the string passed to this function is a valid IPv4 address. - EOS + DOC ) do |arguments| require 'ipaddr' diff --git a/lib/puppet/parser/functions/is_ipv6_address.rb b/lib/puppet/parser/functions/is_ipv6_address.rb index 5fe2bb35d..35be02625 100644 --- a/lib/puppet/parser/functions/is_ipv6_address.rb +++ b/lib/puppet/parser/functions/is_ipv6_address.rb @@ -2,9 +2,9 @@ # is_ipv6_address.rb # module Puppet::Parser::Functions - newfunction(:is_ipv6_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_ipv6_address, :type => :rvalue, :doc => <<-DOC Returns true if the string passed to this function is a valid IPv6 address. - EOS + DOC ) do |arguments| function_deprecation([:is_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/is_mac_address.rb b/lib/puppet/parser/functions/is_mac_address.rb index 11c3ac7cf..83a5ba268 100644 --- a/lib/puppet/parser/functions/is_mac_address.rb +++ b/lib/puppet/parser/functions/is_mac_address.rb @@ -2,9 +2,9 @@ # is_mac_address.rb # module Puppet::Parser::Functions - newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS + newfunction(:is_mac_address, :type => :rvalue, :doc => <<-DOC Returns true if the string passed to this function is a valid mac address. - EOS + DOC ) do |arguments| if arguments.size != 1 diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb index f20ec69ed..e127705df 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -2,7 +2,7 @@ # is_numeric.rb # module Puppet::Parser::Functions - newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS + newfunction(:is_numeric, :type => :rvalue, :doc => <<-DOC Returns true if the given argument is a Numeric (Integer or Float), or a String containing either a valid integer in decimal base 10 form, or a valid floating point string representation. @@ -20,7 +20,7 @@ module Puppet::Parser::Functions -8475 0.2343 -23.561e3 - EOS + DOC ) do |arguments| function_deprecation([:is_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/is_string.rb b/lib/puppet/parser/functions/is_string.rb index 7cc9e0b2f..f7b1b145b 100644 --- a/lib/puppet/parser/functions/is_string.rb +++ b/lib/puppet/parser/functions/is_string.rb @@ -2,9 +2,9 @@ # is_string.rb # module Puppet::Parser::Functions - newfunction(:is_string, :type => :rvalue, :doc => <<-EOS + newfunction(:is_string, :type => :rvalue, :doc => <<-DOC Returns true if the variable passed to this function is a string. - EOS + DOC ) do |arguments| function_deprecation([:is_string, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/join.rb b/lib/puppet/parser/functions/join.rb index 5d26add0f..bcb97b70c 100644 --- a/lib/puppet/parser/functions/join.rb +++ b/lib/puppet/parser/functions/join.rb @@ -2,7 +2,7 @@ # join.rb # module Puppet::Parser::Functions - newfunction(:join, :type => :rvalue, :doc => <<-EOS + newfunction(:join, :type => :rvalue, :doc => <<-DOC This function joins an array into a string using a separator. *Examples:* @@ -10,7 +10,7 @@ module Puppet::Parser::Functions join(['a','b','c'], ",") Would result in: "a,b,c" - EOS + DOC ) do |arguments| # Technically we support two arguments but only first is mandatory ... diff --git a/lib/puppet/parser/functions/join_keys_to_values.rb b/lib/puppet/parser/functions/join_keys_to_values.rb index 5335d3539..1c80d1c88 100644 --- a/lib/puppet/parser/functions/join_keys_to_values.rb +++ b/lib/puppet/parser/functions/join_keys_to_values.rb @@ -2,7 +2,7 @@ # join.rb # module Puppet::Parser::Functions - newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS + newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-DOC This function joins each key of a hash to that key's corresponding value with a separator. Keys are cast to strings. If values are arrays, multiple keys are added for each element. The return value is an array in @@ -17,7 +17,7 @@ module Puppet::Parser::Functions join_keys_to_values({'a'=>1,'b'=>[2,3]}, " is ") Would result in: ["a is 1","b is 2","b is 3"] - EOS + DOC ) do |arguments| # Validate the number of arguments. diff --git a/lib/puppet/parser/functions/keys.rb b/lib/puppet/parser/functions/keys.rb index ebf311712..0ecd48f9e 100644 --- a/lib/puppet/parser/functions/keys.rb +++ b/lib/puppet/parser/functions/keys.rb @@ -2,9 +2,9 @@ # keys.rb # module Puppet::Parser::Functions - newfunction(:keys, :type => :rvalue, :doc => <<-EOS + newfunction(:keys, :type => :rvalue, :doc => <<-DOC Returns the keys of a hash as an array. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/load_module_metadata.rb b/lib/puppet/parser/functions/load_module_metadata.rb index 2b7c11f94..f9a39de95 100644 --- a/lib/puppet/parser/functions/load_module_metadata.rb +++ b/lib/puppet/parser/functions/load_module_metadata.rb @@ -2,9 +2,9 @@ # load_module_metadata.rb # module Puppet::Parser::Functions - newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-EOT + newfunction(:load_module_metadata, :type => :rvalue, :doc => <<-DOC This function loads the metadata of a given module. - EOT + DOC ) do |args| raise(Puppet::ParseError, 'load_module_metadata(): Wrong number of arguments, expects one or two') unless [1, 2].include?(args.size) mod = args[0] diff --git a/lib/puppet/parser/functions/loadjson.rb b/lib/puppet/parser/functions/loadjson.rb index c7bfd734f..9a1d54f32 100644 --- a/lib/puppet/parser/functions/loadjson.rb +++ b/lib/puppet/parser/functions/loadjson.rb @@ -2,7 +2,7 @@ # loadjson.rb # module Puppet::Parser::Functions - newfunction(:loadjson, :type => :rvalue, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:loadjson, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args| Load a JSON file containing an array, string, or hash, and return the data in the corresponding native data type. The second parameter is the default value. It will be returned if the file @@ -12,7 +12,7 @@ module Puppet::Parser::Functions $myhash = loadjson('/etc/puppet/data/myhash.json') $myhash = loadjson('no-file.json', {'default' => 'value'}) - ENDHEREDOC + DOC raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1 diff --git a/lib/puppet/parser/functions/loadyaml.rb b/lib/puppet/parser/functions/loadyaml.rb index 330bd0e8b..a8c9e628c 100644 --- a/lib/puppet/parser/functions/loadyaml.rb +++ b/lib/puppet/parser/functions/loadyaml.rb @@ -2,7 +2,7 @@ # loadyaml.rb # module Puppet::Parser::Functions - newfunction(:loadyaml, :type => :rvalue, :arity => -2, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:loadyaml, :type => :rvalue, :arity => -2, :doc => <<-'DOC') do |args| Load a YAML file containing an array, string, or hash, and return the data in the corresponding native data type. The second parameter is the default value. It will be returned if the file @@ -12,7 +12,7 @@ module Puppet::Parser::Functions $myhash = loadyaml('/etc/puppet/data/myhash.yaml') $myhash = loadyaml('no-file.yaml', {'default' => 'value'}) - ENDHEREDOC + DOC raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless args.length >= 1 require 'yaml' diff --git a/lib/puppet/parser/functions/lstrip.rb b/lib/puppet/parser/functions/lstrip.rb index d3403ad5e..f5b9a5867 100644 --- a/lib/puppet/parser/functions/lstrip.rb +++ b/lib/puppet/parser/functions/lstrip.rb @@ -2,9 +2,9 @@ # lstrip.rb # module Puppet::Parser::Functions - newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS + newfunction(:lstrip, :type => :rvalue, :doc => <<-DOC Strips leading spaces to the left of a string. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "lstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/max.rb b/lib/puppet/parser/functions/max.rb index 517dfae20..21c5245b3 100644 --- a/lib/puppet/parser/functions/max.rb +++ b/lib/puppet/parser/functions/max.rb @@ -2,10 +2,10 @@ # max.rb # module Puppet::Parser::Functions - newfunction(:max, :type => :rvalue, :doc => <<-EOS + newfunction(:max, :type => :rvalue, :doc => <<-DOC Returns the highest value of all arguments. Requires at least one argument. - EOS + DOC ) do |args| raise(Puppet::ParseError, 'max(): Wrong number of arguments need at least one') if args.empty? diff --git a/lib/puppet/parser/functions/member.rb b/lib/puppet/parser/functions/member.rb index 4d746d249..9261080bb 100644 --- a/lib/puppet/parser/functions/member.rb +++ b/lib/puppet/parser/functions/member.rb @@ -4,7 +4,7 @@ # member.rb # module Puppet::Parser::Functions - newfunction(:member, :type => :rvalue, :doc => <<-EOS + newfunction(:member, :type => :rvalue, :doc => <<-DOC This function determines if a variable is a member of an array. The variable can be a string, fixnum, or array. @@ -25,7 +25,7 @@ module Puppet::Parser::Functions member(['a', 'b', 'c'], ['d', 'b']) would return: false - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "member(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 diff --git a/lib/puppet/parser/functions/merge.rb b/lib/puppet/parser/functions/merge.rb index b16cd06ac..25ebc79ff 100644 --- a/lib/puppet/parser/functions/merge.rb +++ b/lib/puppet/parser/functions/merge.rb @@ -2,7 +2,7 @@ # merge.rb # module Puppet::Parser::Functions - newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:merge, :type => :rvalue, :doc => <<-'DOC') do |args| Merges two or more hashes together and returns the resulting hash. For example: @@ -15,7 +15,7 @@ module Puppet::Parser::Functions When there is a duplicate key, the key in the rightmost hash will "win." - ENDHEREDOC + DOC if args.length < 2 raise Puppet::ParseError, "merge(): wrong number of arguments (#{args.length}; must be at least 2)" diff --git a/lib/puppet/parser/functions/min.rb b/lib/puppet/parser/functions/min.rb index 238444308..985ec562f 100644 --- a/lib/puppet/parser/functions/min.rb +++ b/lib/puppet/parser/functions/min.rb @@ -2,10 +2,10 @@ # min.rb # module Puppet::Parser::Functions - newfunction(:min, :type => :rvalue, :doc => <<-EOS + newfunction(:min, :type => :rvalue, :doc => <<-DOC Returns the lowest value of all arguments. Requires at least one argument. - EOS + DOC ) do |args| raise(Puppet::ParseError, 'min(): Wrong number of arguments need at least one') if args.empty? diff --git a/lib/puppet/parser/functions/num2bool.rb b/lib/puppet/parser/functions/num2bool.rb index cd6b0f306..0957c56e3 100644 --- a/lib/puppet/parser/functions/num2bool.rb +++ b/lib/puppet/parser/functions/num2bool.rb @@ -2,11 +2,11 @@ # num2bool.rb # module Puppet::Parser::Functions - newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS + newfunction(:num2bool, :type => :rvalue, :doc => <<-DOC This function converts a number or a string representation of a number into a true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0 become true. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/parsejson.rb b/lib/puppet/parser/functions/parsejson.rb index f33a5fb49..4cc43e677 100644 --- a/lib/puppet/parser/functions/parsejson.rb +++ b/lib/puppet/parser/functions/parsejson.rb @@ -2,13 +2,13 @@ # parsejson.rb # module Puppet::Parser::Functions - newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS + newfunction(:parsejson, :type => :rvalue, :doc => <<-DOC This function accepts JSON as a string and converts it into the correct Puppet structure. The optional second argument can be used to pass a default value that will be returned if the parsing of YAML string have failed. - EOS + DOC ) do |arguments| raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 diff --git a/lib/puppet/parser/functions/parseyaml.rb b/lib/puppet/parser/functions/parseyaml.rb index 35a2f2c0d..7f857ca8d 100644 --- a/lib/puppet/parser/functions/parseyaml.rb +++ b/lib/puppet/parser/functions/parseyaml.rb @@ -2,13 +2,13 @@ # parseyaml.rb # module Puppet::Parser::Functions - newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS + newfunction(:parseyaml, :type => :rvalue, :doc => <<-DOC This function accepts YAML as a string and converts it into the correct Puppet structure. The optional second argument can be used to pass a default value that will be returned if the parsing of YAML string have failed. - EOS + DOC ) do |arguments| raise ArgumentError, 'Wrong number of arguments. 1 or 2 arguments should be provided.' unless arguments.length >= 1 require 'yaml' diff --git a/lib/puppet/parser/functions/pick.rb b/lib/puppet/parser/functions/pick.rb index 70995de50..300e1642f 100644 --- a/lib/puppet/parser/functions/pick.rb +++ b/lib/puppet/parser/functions/pick.rb @@ -2,7 +2,7 @@ # pick.rb # module Puppet::Parser::Functions - newfunction(:pick, :type => :rvalue, :doc => <<-EOS + newfunction(:pick, :type => :rvalue, :doc => <<-DOC This function is similar to a coalesce function in SQL in that it will return the first value in a list of values that is not undefined or an empty string (two things in Puppet that will return a boolean false value). Typically, @@ -15,7 +15,7 @@ module Puppet::Parser::Functions called 'jenkins_version' (note that parameters set in the Puppet Dashboard/ Enterprise Console are brought into Puppet as top-scope variables), and, failing that, will use a default value of 1.449. -EOS +DOC ) do |args| args = args.compact args.delete(:undef) diff --git a/lib/puppet/parser/functions/pick_default.rb b/lib/puppet/parser/functions/pick_default.rb index eba40d546..29aaef27d 100644 --- a/lib/puppet/parser/functions/pick_default.rb +++ b/lib/puppet/parser/functions/pick_default.rb @@ -2,7 +2,7 @@ # pick_default.rb # module Puppet::Parser::Functions - newfunction(:pick_default, :type => :rvalue, :doc => <<-EOS + newfunction(:pick_default, :type => :rvalue, :doc => <<-DOC This function is similar to a coalesce function in SQL in that it will return the first value in a list of values that is not undefined or an empty string (two things in Puppet that will return a boolean false value). If no value is @@ -22,7 +22,7 @@ module Puppet::Parser::Functions Note that, contrary to the pick() function, the pick_default does not fail if all arguments are empty. This allows pick_default to use an empty value as default. -EOS +DOC ) do |args| raise 'Must receive at least one argument.' if args.empty? default = args.last diff --git a/lib/puppet/parser/functions/prefix.rb b/lib/puppet/parser/functions/prefix.rb index 214959877..7490a1845 100644 --- a/lib/puppet/parser/functions/prefix.rb +++ b/lib/puppet/parser/functions/prefix.rb @@ -2,7 +2,7 @@ # prefix.rb # module Puppet::Parser::Functions - newfunction(:prefix, :type => :rvalue, :doc => <<-EOS + newfunction(:prefix, :type => :rvalue, :doc => <<-DOC This function applies a prefix to all elements in an array or a hash. *Examples:* @@ -10,7 +10,7 @@ module Puppet::Parser::Functions prefix(['a','b','c'], 'p') Will return: ['pa','pb','pc'] - EOS + DOC ) do |arguments| # Technically we support two arguments but only first is mandatory ... diff --git a/lib/puppet/parser/functions/private.rb b/lib/puppet/parser/functions/private.rb index c614a1533..5e0b7c560 100644 --- a/lib/puppet/parser/functions/private.rb +++ b/lib/puppet/parser/functions/private.rb @@ -2,10 +2,10 @@ # private.rb # module Puppet::Parser::Functions - newfunction(:private, :doc => <<-'EOS' + newfunction(:private, :doc => <<-'DOC' DEPRECATED: Sets the current class or definition as private. Calling the class or definition from outside the current module will fail. - EOS + DOC ) do |args| warning("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Cannot shorten this line unless Puppet::Parser::Functions.autoloader.loaded?(:assert_private) diff --git a/lib/puppet/parser/functions/pry.rb b/lib/puppet/parser/functions/pry.rb index 4ed532e0a..17b3bc7cb 100644 --- a/lib/puppet/parser/functions/pry.rb +++ b/lib/puppet/parser/functions/pry.rb @@ -2,13 +2,13 @@ # pry.rb # module Puppet::Parser::Functions - newfunction(:pry, :type => :statement, :doc => <<-EOS + newfunction(:pry, :type => :statement, :doc => <<-DOC This function invokes a pry debugging session in the current scope object. This is useful for debugging manifest code at specific points during a compilation. *Examples:* pry() - EOS + DOC ) do |arguments| begin require 'pry' diff --git a/lib/puppet/parser/functions/range.rb b/lib/puppet/parser/functions/range.rb index 489178a30..3e5cc4406 100644 --- a/lib/puppet/parser/functions/range.rb +++ b/lib/puppet/parser/functions/range.rb @@ -3,7 +3,7 @@ # # TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ... module Puppet::Parser::Functions - newfunction(:range, :type => :rvalue, :doc => <<-EOS + newfunction(:range, :type => :rvalue, :doc => <<-DOC When given range in the form of (start, stop) it will extrapolate a range as an array. @@ -32,7 +32,7 @@ module Puppet::Parser::Functions range("0", "9", "2") Will return: [0,2,4,6,8] - EOS + DOC ) do |arguments| raise(Puppet::ParseError, 'range(): Wrong number of arguments given (0 for 1)') if arguments.empty? diff --git a/lib/puppet/parser/functions/regexpescape.rb b/lib/puppet/parser/functions/regexpescape.rb index fbdc02c6b..c64cf445c 100644 --- a/lib/puppet/parser/functions/regexpescape.rb +++ b/lib/puppet/parser/functions/regexpescape.rb @@ -2,10 +2,10 @@ # regexpescape.rb # module Puppet::Parser::Functions - newfunction(:regexpescape, :type => :rvalue, :doc => <<-EOS + newfunction(:regexpescape, :type => :rvalue, :doc => <<-DOC Regexp escape a string or array of strings. Requires either a single string or an array as an input. - EOS + DOC ) do |arguments| # rubocop:disable Style/ClosingParenthesisIndentation raise(Puppet::ParseError, "regexpescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/reject.rb b/lib/puppet/parser/functions/reject.rb index 969a61c98..be2f01769 100644 --- a/lib/puppet/parser/functions/reject.rb +++ b/lib/puppet/parser/functions/reject.rb @@ -2,7 +2,7 @@ # reject.rb # module Puppet::Parser::Functions - newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args| + newfunction(:reject, :type => :rvalue, :doc => <<-DOC) do |args| This function searches through an array and rejects all elements that match the provided regular expression. @@ -13,7 +13,7 @@ module Puppet::Parser::Functions Would return: ['bbb','ccc'] -EOS +DOC if args.size != 2 raise Puppet::ParseError, diff --git a/lib/puppet/parser/functions/reverse.rb b/lib/puppet/parser/functions/reverse.rb index 41184f625..ea911ec3d 100644 --- a/lib/puppet/parser/functions/reverse.rb +++ b/lib/puppet/parser/functions/reverse.rb @@ -2,9 +2,9 @@ # reverse.rb # module Puppet::Parser::Functions - newfunction(:reverse, :type => :rvalue, :doc => <<-EOS + newfunction(:reverse, :type => :rvalue, :doc => <<-DOC Reverses the order of a string or array. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "reverse(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/round.rb b/lib/puppet/parser/functions/round.rb index 8f9553ec6..b4f2c2b15 100644 --- a/lib/puppet/parser/functions/round.rb +++ b/lib/puppet/parser/functions/round.rb @@ -2,7 +2,7 @@ # round.rb # module Puppet::Parser::Functions - newfunction(:round, :type => :rvalue, :doc => <<-EOS + newfunction(:round, :type => :rvalue, :doc => <<-DOC Rounds a number to the nearest integer *Examples:* @@ -15,7 +15,7 @@ module Puppet::Parser::Functions returns: 2 - EOS + DOC ) do |args| raise Puppet::ParseError, "round(): Wrong number of arguments given #{args.size} for 1" if args.size != 1 diff --git a/lib/puppet/parser/functions/rstrip.rb b/lib/puppet/parser/functions/rstrip.rb index 270c8441a..3e04b27ff 100644 --- a/lib/puppet/parser/functions/rstrip.rb +++ b/lib/puppet/parser/functions/rstrip.rb @@ -2,9 +2,9 @@ # rstrip.rb # module Puppet::Parser::Functions - newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS + newfunction(:rstrip, :type => :rvalue, :doc => <<-DOC Strips leading spaces to the right of the string. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "rstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/seeded_rand.rb b/lib/puppet/parser/functions/seeded_rand.rb index 1d283cd4e..0120b87b4 100644 --- a/lib/puppet/parser/functions/seeded_rand.rb +++ b/lib/puppet/parser/functions/seeded_rand.rb @@ -5,13 +5,13 @@ :seeded_rand, :arity => 2, :type => :rvalue, - :doc => <<-EOS + :doc => <<-DOC Usage: `seeded_rand(MAX, SEED)`. MAX must be a positive integer; SEED is any string. Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness. If SEED starts with "$fqdn:", this is behaves the same as `fqdn_rand`. -EOS +DOC ) do |args| require 'digest/md5' diff --git a/lib/puppet/parser/functions/shell_escape.rb b/lib/puppet/parser/functions/shell_escape.rb index d02216100..96fea2088 100644 --- a/lib/puppet/parser/functions/shell_escape.rb +++ b/lib/puppet/parser/functions/shell_escape.rb @@ -3,14 +3,14 @@ # shell_escape.rb # module Puppet::Parser::Functions - newfunction(:shell_escape, :type => :rvalue, :doc => <<-EOS + newfunction(:shell_escape, :type => :rvalue, :doc => <<-DOC Escapes a string so that it can be safely used in a Bourne shell command line. Note that the resulting string should be used unquoted and is not intended for use in double quotes nor in single quotes. This function behaves the same as ruby's Shellwords.shellescape() function. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "shell_escape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/shell_join.rb b/lib/puppet/parser/functions/shell_join.rb index ac7011c72..0a037c1f9 100644 --- a/lib/puppet/parser/functions/shell_join.rb +++ b/lib/puppet/parser/functions/shell_join.rb @@ -4,12 +4,12 @@ # shell_join.rb # module Puppet::Parser::Functions - newfunction(:shell_join, :type => :rvalue, :doc => <<-EOS + newfunction(:shell_join, :type => :rvalue, :doc => <<-DOC Builds a command line string from the given array of strings. Each array item is escaped for Bourne shell. All items are then joined together, with a single space in between. This function behaves the same as ruby's Shellwords.shelljoin() function - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "shell_join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/shell_split.rb b/lib/puppet/parser/functions/shell_split.rb index 390aaeed9..9dcf95884 100644 --- a/lib/puppet/parser/functions/shell_split.rb +++ b/lib/puppet/parser/functions/shell_split.rb @@ -3,11 +3,11 @@ # shell_split.rb # module Puppet::Parser::Functions - newfunction(:shell_split, :type => :rvalue, :doc => <<-EOS + newfunction(:shell_split, :type => :rvalue, :doc => <<-DOC Splits a string into an array of tokens in the same way the Bourne shell does. This function behaves the same as ruby's Shellwords.shellsplit() function - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/shuffle.rb b/lib/puppet/parser/functions/shuffle.rb index a4c59de9c..5e6d93b6f 100644 --- a/lib/puppet/parser/functions/shuffle.rb +++ b/lib/puppet/parser/functions/shuffle.rb @@ -2,9 +2,9 @@ # shuffle.rb # module Puppet::Parser::Functions - newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS + newfunction(:shuffle, :type => :rvalue, :doc => <<-DOC Randomizes the order of a string or array elements. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "shuffle(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/size.rb b/lib/puppet/parser/functions/size.rb index 547b913e3..27f9614ab 100644 --- a/lib/puppet/parser/functions/size.rb +++ b/lib/puppet/parser/functions/size.rb @@ -2,9 +2,9 @@ # size.rb # module Puppet::Parser::Functions - newfunction(:size, :type => :rvalue, :doc => <<-EOS + newfunction(:size, :type => :rvalue, :doc => <<-DOC Returns the number of elements in a string, an array or a hash - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/sort.rb b/lib/puppet/parser/functions/sort.rb index e28eaf36b..f0b4a144f 100644 --- a/lib/puppet/parser/functions/sort.rb +++ b/lib/puppet/parser/functions/sort.rb @@ -3,9 +3,9 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:sort, :type => :rvalue, :doc => <<-EOS + newfunction(:sort, :type => :rvalue, :doc => <<-DOC Sorts strings and arrays lexically. - EOS + DOC ) do |arguments| if arguments.size != 1 diff --git a/lib/puppet/parser/functions/squeeze.rb b/lib/puppet/parser/functions/squeeze.rb index d6a9183f9..eaa140414 100644 --- a/lib/puppet/parser/functions/squeeze.rb +++ b/lib/puppet/parser/functions/squeeze.rb @@ -2,9 +2,9 @@ # squeeze.rb # module Puppet::Parser::Functions - newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS + newfunction(:squeeze, :type => :rvalue, :doc => <<-DOC Returns a new string where runs of the same character that occur in this set are replaced by a single character. - EOS + DOC ) do |arguments| if (arguments.size != 2) && (arguments.size != 1) diff --git a/lib/puppet/parser/functions/str2bool.rb b/lib/puppet/parser/functions/str2bool.rb index aca521054..95c260ccb 100644 --- a/lib/puppet/parser/functions/str2bool.rb +++ b/lib/puppet/parser/functions/str2bool.rb @@ -2,11 +2,11 @@ # str2bool.rb # module Puppet::Parser::Functions - newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS + newfunction(:str2bool, :type => :rvalue, :doc => <<-DOC This converts a string to a boolean. This attempt to convert strings that contain things like: Y,y, 1, T,t, TRUE,true to 'true' and strings that contain things like: 0, F,f, N,n, false, FALSE, no to 'false'. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "str2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/str2saltedsha512.rb b/lib/puppet/parser/functions/str2saltedsha512.rb index c53d0e33a..4d62008b7 100644 --- a/lib/puppet/parser/functions/str2saltedsha512.rb +++ b/lib/puppet/parser/functions/str2saltedsha512.rb @@ -3,12 +3,12 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS + newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-DOC This converts a string to a salted-SHA512 password hash (which is used for OS X versions >= 10.7). Given any simple string, you will get a hex version of a salted-SHA512 password hash that can be inserted into your Puppet manifests as a valid password attribute. - EOS + DOC ) do |arguments| require 'digest/sha2' diff --git a/lib/puppet/parser/functions/strftime.rb b/lib/puppet/parser/functions/strftime.rb index 36902f120..53cf7490f 100644 --- a/lib/puppet/parser/functions/strftime.rb +++ b/lib/puppet/parser/functions/strftime.rb @@ -3,7 +3,7 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:strftime, :type => :rvalue, :doc => <<-EOS + newfunction(:strftime, :type => :rvalue, :doc => <<-DOC This function returns formatted time. *Examples:* @@ -67,7 +67,7 @@ module Puppet::Parser::Functions %z - Time zone as hour offset from UTC (e.g. +0900) %Z - Time zone name %% - Literal ``%'' character - EOS + DOC ) do |arguments| # Technically we support two arguments but only first is mandatory ... diff --git a/lib/puppet/parser/functions/strip.rb b/lib/puppet/parser/functions/strip.rb index fbd28e788..6a147cd20 100644 --- a/lib/puppet/parser/functions/strip.rb +++ b/lib/puppet/parser/functions/strip.rb @@ -2,7 +2,7 @@ # strip.rb # module Puppet::Parser::Functions - newfunction(:strip, :type => :rvalue, :doc => <<-EOS + newfunction(:strip, :type => :rvalue, :doc => <<-DOC This function removes leading and trailing whitespace from a string or from every string inside an array. @@ -11,7 +11,7 @@ module Puppet::Parser::Functions strip(" aaa ") Would result in: "aaa" - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/suffix.rb b/lib/puppet/parser/functions/suffix.rb index 067113c6d..407cd53a6 100644 --- a/lib/puppet/parser/functions/suffix.rb +++ b/lib/puppet/parser/functions/suffix.rb @@ -2,7 +2,7 @@ # suffix.rb # module Puppet::Parser::Functions - newfunction(:suffix, :type => :rvalue, :doc => <<-EOS + newfunction(:suffix, :type => :rvalue, :doc => <<-DOC This function applies a suffix to all elements in an array, or to the keys in a hash. @@ -11,7 +11,7 @@ module Puppet::Parser::Functions suffix(['a','b','c'], 'p') Will return: ['ap','bp','cp'] - EOS + DOC ) do |arguments| # Technically we support two arguments but only first is mandatory ... diff --git a/lib/puppet/parser/functions/swapcase.rb b/lib/puppet/parser/functions/swapcase.rb index a004e0904..e8a5d9a8f 100644 --- a/lib/puppet/parser/functions/swapcase.rb +++ b/lib/puppet/parser/functions/swapcase.rb @@ -3,7 +3,7 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS + newfunction(:swapcase, :type => :rvalue, :doc => <<-DOC This function will swap the existing case of a string. *Examples:* @@ -11,7 +11,7 @@ module Puppet::Parser::Functions swapcase("aBcD") Would result in: "AbCd" - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "swapcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/time.rb b/lib/puppet/parser/functions/time.rb index 4239785bb..021a48381 100644 --- a/lib/puppet/parser/functions/time.rb +++ b/lib/puppet/parser/functions/time.rb @@ -2,7 +2,7 @@ # time.rb # module Puppet::Parser::Functions - newfunction(:time, :type => :rvalue, :doc => <<-EOS + newfunction(:time, :type => :rvalue, :doc => <<-DOC This function will return the current time since epoch as an integer. *Examples:* @@ -10,7 +10,7 @@ module Puppet::Parser::Functions time() Will return something like: 1311972653 - EOS + DOC ) do |arguments| # The Time Zone argument is optional ... diff --git a/lib/puppet/parser/functions/to_bytes.rb b/lib/puppet/parser/functions/to_bytes.rb index 18d0edbb0..bff24b070 100644 --- a/lib/puppet/parser/functions/to_bytes.rb +++ b/lib/puppet/parser/functions/to_bytes.rb @@ -2,12 +2,12 @@ # to_bytes.rb # module Puppet::Parser::Functions - newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS + newfunction(:to_bytes, :type => :rvalue, :doc => <<-DOC Converts the argument into bytes, for example 4 kB becomes 4096. Takes a single string value as an argument. These conversions reflect a layperson's understanding of 1 MB = 1024 KB, when in fact 1 MB = 1000 KB, and 1 MiB = 1024 KiB. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/try_get_value.rb b/lib/puppet/parser/functions/try_get_value.rb index e722390e6..34f94762e 100644 --- a/lib/puppet/parser/functions/try_get_value.rb +++ b/lib/puppet/parser/functions/try_get_value.rb @@ -6,7 +6,7 @@ module Puppet::Parser::Functions :try_get_value, :type => :rvalue, :arity => -2, - :doc => <<-eos + :doc => <<-DOC DEPRECATED: this function is deprecated, please use dig() instead. Looks up into a complex structure of arrays and hashes and returns a value @@ -38,7 +38,7 @@ module Puppet::Parser::Functions In addition to the required "key" argument, "try_get_value" accepts default argument. It will be returned if no value was found or a path component is missing. And the fourth argument can set a variable path separator. - eos + DOC ) do |args| warning('try_get_value() DEPRECATED: this function is deprecated, please use dig() instead.') data = args[0] diff --git a/lib/puppet/parser/functions/type.rb b/lib/puppet/parser/functions/type.rb index e43c44e03..bda2efbcc 100644 --- a/lib/puppet/parser/functions/type.rb +++ b/lib/puppet/parser/functions/type.rb @@ -2,9 +2,9 @@ # type.rb # module Puppet::Parser::Functions - newfunction(:type, :type => :rvalue, :doc => <<-EOS + newfunction(:type, :type => :rvalue, :doc => <<-DOC DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system. - EOS + DOC ) do |args| warning("type() DEPRECATED: This function will cease to function on Puppet 4; please use type3x() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : Cannot reduce line length diff --git a/lib/puppet/parser/functions/type3x.rb b/lib/puppet/parser/functions/type3x.rb index f78df4cd9..35d62b58c 100644 --- a/lib/puppet/parser/functions/type3x.rb +++ b/lib/puppet/parser/functions/type3x.rb @@ -2,7 +2,7 @@ # type3x.rb # module Puppet::Parser::Functions - newfunction(:type3x, :type => :rvalue, :doc => <<-EOS + newfunction(:type3x, :type => :rvalue, :doc => <<-DOC DEPRECATED: This function will be removed when puppet 3 support is dropped; please migrate to the new parser's typing system. Returns the type when passed a value. Type can be one of: @@ -13,7 +13,7 @@ module Puppet::Parser::Functions * float * integer * boolean - EOS + DOC ) do |args| raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") if args.empty? diff --git a/lib/puppet/parser/functions/union.rb b/lib/puppet/parser/functions/union.rb index 033502fa6..ed57bc5d9 100644 --- a/lib/puppet/parser/functions/union.rb +++ b/lib/puppet/parser/functions/union.rb @@ -2,7 +2,7 @@ # union.rb # module Puppet::Parser::Functions - newfunction(:union, :type => :rvalue, :doc => <<-EOS + newfunction(:union, :type => :rvalue, :doc => <<-DOC This function returns a union of two or more arrays. *Examples:* @@ -10,7 +10,7 @@ module Puppet::Parser::Functions union(["a","b","c"],["b","c","d"]) Would return: ["a","b","c","d"] - EOS + DOC ) do |arguments| # Check that 2 or more arguments have been given ... diff --git a/lib/puppet/parser/functions/unique.rb b/lib/puppet/parser/functions/unique.rb index 2a1939be4..301f6a410 100644 --- a/lib/puppet/parser/functions/unique.rb +++ b/lib/puppet/parser/functions/unique.rb @@ -2,7 +2,7 @@ # unique.rb # module Puppet::Parser::Functions - newfunction(:unique, :type => :rvalue, :doc => <<-EOS + newfunction(:unique, :type => :rvalue, :doc => <<-DOC This function will remove duplicates from strings and arrays. *Examples:* @@ -20,7 +20,7 @@ module Puppet::Parser::Functions This returns: ["a","b","c"] - EOS + DOC ) do |arguments| if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 diff --git a/lib/puppet/parser/functions/unix2dos.rb b/lib/puppet/parser/functions/unix2dos.rb index ccfc45dbe..8123797f4 100644 --- a/lib/puppet/parser/functions/unix2dos.rb +++ b/lib/puppet/parser/functions/unix2dos.rb @@ -1,9 +1,9 @@ # Custom Puppet function to convert unix to dos format module Puppet::Parser::Functions - newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-EOS + newfunction(:unix2dos, :type => :rvalue, :arity => 1, :doc => <<-DOC Returns the DOS version of the given string. Takes a single string argument. - EOS + DOC ) do |arguments| unless arguments[0].is_a?(String) diff --git a/lib/puppet/parser/functions/upcase.rb b/lib/puppet/parser/functions/upcase.rb index 9e04cdc4c..42e611497 100644 --- a/lib/puppet/parser/functions/upcase.rb +++ b/lib/puppet/parser/functions/upcase.rb @@ -3,7 +3,7 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:upcase, :type => :rvalue, :doc => <<-EOS + newfunction(:upcase, :type => :rvalue, :doc => <<-DOC Converts a string or an array of strings to uppercase. *Examples:* @@ -13,7 +13,7 @@ module Puppet::Parser::Functions Will return: ABCD - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "upcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 diff --git a/lib/puppet/parser/functions/uriescape.rb b/lib/puppet/parser/functions/uriescape.rb index 6b44b3724..2c9ab32e4 100644 --- a/lib/puppet/parser/functions/uriescape.rb +++ b/lib/puppet/parser/functions/uriescape.rb @@ -4,10 +4,10 @@ # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # module Puppet::Parser::Functions - newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS + newfunction(:uriescape, :type => :rvalue, :doc => <<-DOC Urlencodes a string or array of strings. Requires either a single string or an array as an input. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "uriescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? @@ -20,9 +20,9 @@ module Puppet::Parser::Functions result = if value.is_a?(Array) # Numbers in Puppet are often string-encoded which is troublesome ... - value.map { |i| i.is_a?(String) ? URI.escape(i) : i } + value.map { |i| i.is_a?(String) ? URI.escape(i) : i } # rubocop:disable Lint/UriEscapeUnescape else - URI.escape(value) + URI.escape(value) # rubocop:disable Lint/UriEscapeUnescape end return result diff --git a/lib/puppet/parser/functions/validate_absolute_path.rb b/lib/puppet/parser/functions/validate_absolute_path.rb index 16de3d020..0db10c3f5 100644 --- a/lib/puppet/parser/functions/validate_absolute_path.rb +++ b/lib/puppet/parser/functions/validate_absolute_path.rb @@ -2,7 +2,7 @@ # validate_absolute_path.rb # module Puppet::Parser::Functions - newfunction(:validate_absolute_path, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_absolute_path, :doc => <<-'DOC') do |args| Validate the string represents an absolute path in the filesystem. This function works for windows and unix style paths. @@ -27,7 +27,7 @@ module Puppet::Parser::Functions $undefined = undef validate_absolute_path($undefined) - ENDHEREDOC + DOC require 'puppet/util' diff --git a/lib/puppet/parser/functions/validate_array.rb b/lib/puppet/parser/functions/validate_array.rb index eb82cdb7f..1120ce8bb 100644 --- a/lib/puppet/parser/functions/validate_array.rb +++ b/lib/puppet/parser/functions/validate_array.rb @@ -2,7 +2,7 @@ # validate_array.rb # module Puppet::Parser::Functions - newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_array, :doc => <<-'DOC') do |args| Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check. @@ -18,7 +18,7 @@ module Puppet::Parser::Functions $undefined = undef validate_array($undefined) - ENDHEREDOC + DOC function_deprecation([:validate_array, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Array. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_augeas.rb b/lib/puppet/parser/functions/validate_augeas.rb index 4b5ab063c..97f3127e3 100644 --- a/lib/puppet/parser/functions/validate_augeas.rb +++ b/lib/puppet/parser/functions/validate_augeas.rb @@ -4,7 +4,7 @@ # validate_augaes.rb # module Puppet::Parser::Functions - newfunction(:validate_augeas, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_augeas, :doc => <<-'DOC') do |args| Perform validation of a string using an Augeas lens The first argument of this function should be a string to test, and the second argument should be the name of the Augeas lens to use. @@ -32,7 +32,7 @@ module Puppet::Parser::Functions validate_augeas($sudoerscontent, 'Sudoers.lns', [], 'Failed to validate sudoers content with Augeas') - ENDHEREDOC + DOC unless Puppet.features.augeas? raise Puppet::ParseError, 'validate_augeas(): this function requires the augeas feature. See http://docs.puppetlabs.com/guides/augeas.html#pre-requisites for how to activate it.' end diff --git a/lib/puppet/parser/functions/validate_bool.rb b/lib/puppet/parser/functions/validate_bool.rb index 7e269336a..d3bf3d021 100644 --- a/lib/puppet/parser/functions/validate_bool.rb +++ b/lib/puppet/parser/functions/validate_bool.rb @@ -2,7 +2,7 @@ # validate_bool.rb # module Puppet::Parser::Functions - newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_bool, :doc => <<-'DOC') do |args| Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check. @@ -19,7 +19,7 @@ module Puppet::Parser::Functions validate_bool("true") validate_bool($some_array) - ENDHEREDOC + DOC if args.empty? raise Puppet::ParseError, "validate_bool(): wrong number of arguments (#{args.length}; must be > 0)" diff --git a/lib/puppet/parser/functions/validate_cmd.rb b/lib/puppet/parser/functions/validate_cmd.rb index 9e74a3d46..dbea604df 100644 --- a/lib/puppet/parser/functions/validate_cmd.rb +++ b/lib/puppet/parser/functions/validate_cmd.rb @@ -5,7 +5,7 @@ # validate_cmd.rb # module Puppet::Parser::Functions - newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_cmd, :doc => <<-'DOC') do |args| Perform validation of a string with an external command. The first argument of this function should be a string to test, and the second argument should be a path to a test command @@ -26,7 +26,7 @@ module Puppet::Parser::Functions # % as file location validate_cmd($haproxycontent, '/usr/sbin/haproxy -f % -c', 'Haproxy failed to validate config content') - ENDHEREDOC + DOC if (args.length < 2) || (args.length > 3) raise Puppet::ParseError, "validate_cmd(): wrong number of arguments (#{args.length}; must be 2 or 3)" end diff --git a/lib/puppet/parser/functions/validate_domain_name.rb b/lib/puppet/parser/functions/validate_domain_name.rb index 58c9d3a80..c479dfb43 100644 --- a/lib/puppet/parser/functions/validate_domain_name.rb +++ b/lib/puppet/parser/functions/validate_domain_name.rb @@ -2,7 +2,7 @@ # validate_domain_name.rb # module Puppet::Parser::Functions - newfunction(:validate_domain_name, :doc => <<-ENDHEREDOC + newfunction(:validate_domain_name, :doc => <<-DOC Validate that all values passed are syntactically correct domain names. Fail compilation if any value fails this check. @@ -20,7 +20,7 @@ module Puppet::Parser::Functions validate_domain_name('-foo.example.com') validate_domain_name('www.example.2com') - ENDHEREDOC + DOC ) do |args| rescuable_exceptions = [ArgumentError] diff --git a/lib/puppet/parser/functions/validate_email_address.rb b/lib/puppet/parser/functions/validate_email_address.rb index 779710005..a039f5105 100644 --- a/lib/puppet/parser/functions/validate_email_address.rb +++ b/lib/puppet/parser/functions/validate_email_address.rb @@ -2,7 +2,7 @@ # validate_email_address.rb # module Puppet::Parser::Functions - newfunction(:validate_email_address, :doc => <<-ENDHEREDOC + newfunction(:validate_email_address, :doc => <<-DOC Validate that all values passed are valid email addresses. Fail compilation if any value fails this check. The following values will pass: @@ -13,7 +13,7 @@ module Puppet::Parser::Functions The following values will fail, causing compilation to abort: $some_array = [ 'bad_email@/d/efdf.com' ] validate_email_address($some_array) - ENDHEREDOC + DOC ) do |args| rescuable_exceptions = [ArgumentError] diff --git a/lib/puppet/parser/functions/validate_hash.rb b/lib/puppet/parser/functions/validate_hash.rb index 14685d7bc..0460cf35b 100644 --- a/lib/puppet/parser/functions/validate_hash.rb +++ b/lib/puppet/parser/functions/validate_hash.rb @@ -2,7 +2,7 @@ # validate_hash.rb # module Puppet::Parser::Functions - newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_hash, :doc => <<-'DOC') do |args| Validate that all passed values are hash data structures. Abort catalog compilation if any value fails this check. @@ -18,7 +18,7 @@ module Puppet::Parser::Functions $undefined = undef validate_hash($undefined) - ENDHEREDOC + DOC function_deprecation([:validate_hash, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Hash. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_integer.rb b/lib/puppet/parser/functions/validate_integer.rb index 93d8cc554..fc50bdc92 100644 --- a/lib/puppet/parser/functions/validate_integer.rb +++ b/lib/puppet/parser/functions/validate_integer.rb @@ -2,7 +2,7 @@ # validate_interger.rb # module Puppet::Parser::Functions - newfunction(:validate_integer, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_integer, :doc => <<-'DOC') do |args| Validate that the first argument is an integer (or an array of integers). Abort catalog compilation if any of the checks fail. The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. @@ -53,7 +53,7 @@ module Puppet::Parser::Functions Plus all of the above, but with incorrect combinations of negative integer values. Plus all of the above, but with non-integer items in arrays or maximum / minimum argument. - ENDHEREDOC + DOC function_deprecation([:validate_integer, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Integer. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_ip_address.rb b/lib/puppet/parser/functions/validate_ip_address.rb index dba0d9659..af835adf0 100644 --- a/lib/puppet/parser/functions/validate_ip_address.rb +++ b/lib/puppet/parser/functions/validate_ip_address.rb @@ -2,7 +2,7 @@ # validate_ip_address.rb # module Puppet::Parser::Functions - newfunction(:validate_ip_address, :doc => <<-ENDHEREDOC + newfunction(:validate_ip_address, :doc => <<-DOC Validate that all values passed are valid IP addresses, regardless they are IPv4 or IPv6 Fail compilation if any value fails this check. @@ -19,7 +19,7 @@ module Puppet::Parser::Functions The following values will fail, causing compilation to abort: $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] validate_ip_address($some_array) - ENDHEREDOC + DOC ) do |args| require 'ipaddr' diff --git a/lib/puppet/parser/functions/validate_ipv4_address.rb b/lib/puppet/parser/functions/validate_ipv4_address.rb index 9da53e7fd..1ac303f10 100644 --- a/lib/puppet/parser/functions/validate_ipv4_address.rb +++ b/lib/puppet/parser/functions/validate_ipv4_address.rb @@ -2,7 +2,7 @@ # validate_ipv4_address.rb # module Puppet::Parser::Functions - newfunction(:validate_ipv4_address, :doc => <<-ENDHEREDOC + newfunction(:validate_ipv4_address, :doc => <<-DOC Validate that all values passed are valid IPv4 addresses. Fail compilation if any value fails this check. @@ -17,7 +17,7 @@ module Puppet::Parser::Functions $some_array = [ 1, true, false, "garbage string", "3ffe:505:2" ] validate_ipv4_address($some_array) - ENDHEREDOC + DOC ) do |args| function_deprecation([:validate_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/validate_ipv6_address.rb b/lib/puppet/parser/functions/validate_ipv6_address.rb index 611b546ba..88c133cd2 100644 --- a/lib/puppet/parser/functions/validate_ipv6_address.rb +++ b/lib/puppet/parser/functions/validate_ipv6_address.rb @@ -2,7 +2,7 @@ # validate_ipv7_address.rb # module Puppet::Parser::Functions - newfunction(:validate_ipv6_address, :doc => <<-ENDHEREDOC + newfunction(:validate_ipv6_address, :doc => <<-DOC Validate that all values passed are valid IPv6 addresses. Fail compilation if any value fails this check. @@ -18,7 +18,7 @@ module Puppet::Parser::Functions $some_array = [ true, false, "garbage string", "1.2.3.4" ] validate_ipv6_address($some_array) - ENDHEREDOC + DOC ) do |args| function_deprecation([:validate_ipv6_address, 'This method is deprecated, please use the stdlib validate_legacy function, diff --git a/lib/puppet/parser/functions/validate_numeric.rb b/lib/puppet/parser/functions/validate_numeric.rb index 72069094f..803e6f01a 100644 --- a/lib/puppet/parser/functions/validate_numeric.rb +++ b/lib/puppet/parser/functions/validate_numeric.rb @@ -2,7 +2,7 @@ # validate_numeric.rb # module Puppet::Parser::Functions - newfunction(:validate_numeric, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_numeric, :doc => <<-'DOC') do |args| Validate that the first argument is a numeric value (or an array of numeric values). Abort catalog compilation if any of the checks fail. The second argument is optional and passes a maximum. (All elements of) the first argument has to be less or equal to this max. @@ -15,7 +15,7 @@ module Puppet::Parser::Functions For passing and failing usage, see `validate_integer()`. It is all the same for validate_numeric, yet now floating point values are allowed, too. - ENDHEREDOC + DOC function_deprecation([:validate_numeric, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Numeric. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_re.rb b/lib/puppet/parser/functions/validate_re.rb index 1fb59ef36..88f23fcc7 100644 --- a/lib/puppet/parser/functions/validate_re.rb +++ b/lib/puppet/parser/functions/validate_re.rb @@ -2,7 +2,7 @@ # validate.rb # module Puppet::Parser::Functions - newfunction(:validate_re, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_re, :doc => <<-'DOC') do |args| Perform simple validation of a string against one or more regular expressions. The first argument of this function should be a string to test, and the second argument should be a stringified regular expression @@ -31,7 +31,7 @@ module Puppet::Parser::Functions validate_re("${::operatingsystemmajrelease}", '^[57]$') - ENDHEREDOC + DOC function_deprecation([:validate_re, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Re. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_slength.rb b/lib/puppet/parser/functions/validate_slength.rb index 92573eb5e..db5010e2a 100644 --- a/lib/puppet/parser/functions/validate_slength.rb +++ b/lib/puppet/parser/functions/validate_slength.rb @@ -2,7 +2,7 @@ # validate_slength.rb # module Puppet::Parser::Functions - newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_slength, :doc => <<-'DOC') do |args| Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. An optional third parameter can be given the minimum length. It fails if the first @@ -21,7 +21,7 @@ module Puppet::Parser::Functions validate_slength(["discombobulate","thermometer"],5) validate_slength(["discombobulate","moo"],17,10) - ENDHEREDOC + DOC function_deprecation([:validate_slength, 'This method is deprecated, please use the stdlib validate_legacy function, with String[]. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_string.rb b/lib/puppet/parser/functions/validate_string.rb index c15049969..c2847b648 100644 --- a/lib/puppet/parser/functions/validate_string.rb +++ b/lib/puppet/parser/functions/validate_string.rb @@ -2,7 +2,7 @@ # validate_String.rb # module Puppet::Parser::Functions - newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args| + newfunction(:validate_string, :doc => <<-'DOC') do |args| Validate that all passed values are string data structures. Abort catalog compilation if any value fails this check. @@ -23,7 +23,7 @@ module Puppet::Parser::Functions fail('...') } - ENDHEREDOC + DOC function_deprecation([:validate_string, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::String. There is further documentation for validate_legacy function in the README.']) diff --git a/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb b/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb index 2dcc48e91..ea69dc4be 100644 --- a/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb +++ b/lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb @@ -2,7 +2,7 @@ # validate_x509_rsa_key_pair.rb # module Puppet::Parser::Functions - newfunction(:validate_x509_rsa_key_pair, :doc => <<-ENDHEREDOC + newfunction(:validate_x509_rsa_key_pair, :doc => <<-DOC Validates a PEM-formatted X.509 certificate and RSA private key using OpenSSL. Verifies that the certficate's signature was created from the supplied key. @@ -11,7 +11,7 @@ module Puppet::Parser::Functions validate_x509_rsa_key_pair($cert, $key) - ENDHEREDOC + DOC ) do |args| require 'openssl' diff --git a/lib/puppet/parser/functions/values.rb b/lib/puppet/parser/functions/values.rb index 4290e56dc..168da84b6 100644 --- a/lib/puppet/parser/functions/values.rb +++ b/lib/puppet/parser/functions/values.rb @@ -2,7 +2,7 @@ # values.rb # module Puppet::Parser::Functions - newfunction(:values, :type => :rvalue, :doc => <<-EOS + newfunction(:values, :type => :rvalue, :doc => <<-DOC When given a hash this function will return the values of that hash. *Examples:* @@ -17,7 +17,7 @@ module Puppet::Parser::Functions This example would return: [1,2,3] - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? diff --git a/lib/puppet/parser/functions/values_at.rb b/lib/puppet/parser/functions/values_at.rb index 0016551ee..2e075526e 100644 --- a/lib/puppet/parser/functions/values_at.rb +++ b/lib/puppet/parser/functions/values_at.rb @@ -2,7 +2,7 @@ # values_at.rb # module Puppet::Parser::Functions - newfunction(:values_at, :type => :rvalue, :doc => <<-EOS + newfunction(:values_at, :type => :rvalue, :doc => <<-DOC Finds value inside an array based on location. The first argument is the array you want to analyze, and the second element can @@ -25,7 +25,7 @@ module Puppet::Parser::Functions values_at(['a','b','c','d','e'], [0, "2-3"]) Would return ['a','c','d']. - EOS + DOC ) do |arguments| raise(Puppet::ParseError, "values_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 diff --git a/lib/puppet/parser/functions/zip.rb b/lib/puppet/parser/functions/zip.rb index 3e731c5b7..87a89f824 100644 --- a/lib/puppet/parser/functions/zip.rb +++ b/lib/puppet/parser/functions/zip.rb @@ -2,7 +2,7 @@ # zip.rb # module Puppet::Parser::Functions - newfunction(:zip, :type => :rvalue, :doc => <<-EOS + newfunction(:zip, :type => :rvalue, :doc => <<-DOC Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments. *Example:* @@ -12,7 +12,7 @@ module Puppet::Parser::Functions Would result in: ["1", "4"], ["2", "5"], ["3", "6"] - EOS + DOC ) do |arguments| # Technically we support three arguments but only first is mandatory ... diff --git a/lib/puppet/provider/file_line/ruby.rb b/lib/puppet/provider/file_line/ruby.rb index a42f5809c..84233003f 100644 --- a/lib/puppet/provider/file_line/ruby.rb +++ b/lib/puppet/provider/file_line/ruby.rb @@ -23,11 +23,7 @@ def exists? elsif resource[:replace_all_matches_not_matching_line].to_s == 'true' false # maybe lies, but knows there's still work to do elsif lines_count.zero? - if resource[:replace].to_s == 'false' - true - else - false - end + resource[:replace].to_s == 'false' else true end @@ -38,11 +34,7 @@ def exists? true end elsif lines_count.zero? - if resource[:match_for_absence].to_s == 'true' - true # found matches, not lines - else - false - end + resource[:match_for_absence].to_s == 'true' else true end diff --git a/lib/puppet/type/anchor.rb b/lib/puppet/type/anchor.rb index 843334ba9..60cfa6451 100644 --- a/lib/puppet/type/anchor.rb +++ b/lib/puppet/type/anchor.rb @@ -1,5 +1,5 @@ Puppet::Type.newtype(:anchor) do - desc <<-'ENDOFDESC' + desc <<-'DESCRIPTION' A simple resource type intended to be used as an anchor in a composite class. In Puppet 2.6, when a class declares another class, the resources in the @@ -32,7 +32,7 @@ class { 'ntp::package': } class { 'ntp': } -> class { 'mcollective': } class { 'mcollective': } -> class { 'ntp': } - ENDOFDESC + DESCRIPTION newparam :name do desc 'The name of the anchor resource.' diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 274bb2947..14650fe06 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -1,5 +1,5 @@ Puppet::Type.newtype(:file_line) do - desc <<-EOT + desc <<-DOC Ensures that a given line is contained within a file. The implementation matches the full line, including whitespace at the beginning and end. If the line is not contained in the given file, Puppet will append the line to @@ -85,7 +85,7 @@ **Autorequires:** If Puppet is managing the file that will contain the line being managed, the file_line resource will autorequire that file. - EOT + DOC ensurable do defaultvalues diff --git a/spec/acceptance/abs_spec.rb b/spec/acceptance/abs_spec.rb index b4cc09e06..40a0dcd8f 100755 --- a/spec/acceptance/abs_spec.rb +++ b/spec/acceptance/abs_spec.rb @@ -3,22 +3,22 @@ describe 'abs function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $input = '-34.56' $output = abs($input) notify { "$output": } - EOS + DOC it 'accepts a string' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: 34.56}) end end - pp2 = <<-EOS + pp2 = <<-DOC $input = -35.46 $output = abs($input) notify { "$output": } - EOS + DOC it 'accepts a float' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: 35.46}) diff --git a/spec/acceptance/anchor_spec.rb b/spec/acceptance/anchor_spec.rb index 2f4c269de..3cf0c929e 100755 --- a/spec/acceptance/anchor_spec.rb +++ b/spec/acceptance/anchor_spec.rb @@ -2,7 +2,7 @@ describe 'anchor type' do describe 'success' do - pp = <<-EOS + pp = <<-DOC class anchored { anchor { 'anchored::begin': } ~> anchor { 'anchored::end': } @@ -15,7 +15,7 @@ class anchorrefresh { } include anchorrefresh - EOS + DOC it 'effects proper chaining of resources' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Anchor\[final\]: Triggered 'refresh'}) diff --git a/spec/acceptance/any2array_spec.rb b/spec/acceptance/any2array_spec.rb index 23b10ba96..8972f8508 100755 --- a/spec/acceptance/any2array_spec.rb +++ b/spec/acceptance/any2array_spec.rb @@ -3,31 +3,31 @@ describe 'any2array function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $input = '' $output = any2array($input) validate_array($output) notify { "Output: ${output}": } - EOS + DOC it 'creates an empty array' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: Output: }) end end - pp2 = <<-EOS + pp2 = <<-DOC $input = ['array', 'test'] $output = any2array($input) validate_array($output) notify { "Output: ${output}": } - EOS + DOC it 'leaves arrays modified' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: Output: (\[|)array(,\s|)test(\]|)}) end end - pp3 = <<-EOS + pp3 = <<-DOC $input = {'test' => 'array'} $output = any2array($input) @@ -36,7 +36,7 @@ validate_string($output[0]) validate_string($output[1]) notify { "Output: ${output}": } - EOS + DOC it 'turns a hash into an array' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: Output: (\[|)test(,\s|)array(\]|)}) diff --git a/spec/acceptance/base64_spec.rb b/spec/acceptance/base64_spec.rb index 7b31dde7f..a1c8e57a7 100755 --- a/spec/acceptance/base64_spec.rb +++ b/spec/acceptance/base64_spec.rb @@ -3,11 +3,11 @@ describe 'base64 function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $encodestring = base64('encode', 'thestring') $decodestring = base64('decode', $encodestring) notify { $decodestring: } - EOS + DOC it 'encodes then decode a string' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{thestring}) diff --git a/spec/acceptance/bool2num_spec.rb b/spec/acceptance/bool2num_spec.rb index 239aabd97..059e19f20 100755 --- a/spec/acceptance/bool2num_spec.rb +++ b/spec/acceptance/bool2num_spec.rb @@ -4,11 +4,11 @@ describe 'bool2num function' do describe 'success' do %w[false f 0 n no].each do |bool| - pp1 = <<-EOS + pp1 = <<-DOC $input = "#{bool}" $output = bool2num($input) notify { "$output": } - EOS + DOC it "should convert a given boolean, #{bool}, to 0" do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: 0}) @@ -17,11 +17,11 @@ end %w[true t 1 y yes].each do |bool| - pp2 = <<-EOS + pp2 = <<-DOC $input = "#{bool}" $output = bool2num($input) notify { "$output": } - EOS + DOC it "should convert a given boolean, #{bool}, to 1" do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: 1}) diff --git a/spec/acceptance/capitalize_spec.rb b/spec/acceptance/capitalize_spec.rb index 17b37aafc..322f6fc89 100755 --- a/spec/acceptance/capitalize_spec.rb +++ b/spec/acceptance/capitalize_spec.rb @@ -3,22 +3,22 @@ describe 'capitalize function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $input = 'this is a string' $output = capitalize($input) notify { $output: } - EOS + DOC it 'capitalizes the first letter of a string' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: This is a string}) end end - pp2 = <<-EOS + pp2 = <<-DOC $input = ['this', 'is', 'a', 'string'] $output = capitalize($input) notify { $output: } - EOS + DOC regex_array = [%r{Notice: This}, %r{Notice: Is}, %r{Notice: A}, %r{Notice: String}] it 'capitalizes the first letter of an array of strings' do apply_manifest(pp2, :catch_failures => true) do |r| diff --git a/spec/acceptance/ceiling_spec.rb b/spec/acceptance/ceiling_spec.rb index 6d9e10e5f..881fce837 100755 --- a/spec/acceptance/ceiling_spec.rb +++ b/spec/acceptance/ceiling_spec.rb @@ -3,28 +3,28 @@ describe 'ceiling function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = 12.8 $b = 13 $o = ceiling($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'ceilings floats' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = 7 $b = 7 $o = ceiling($a) if $o == $b { notify { 'output is correct': } } - EOS + DOC it 'ceilings integers' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output is correct}) diff --git a/spec/acceptance/chomp_spec.rb b/spec/acceptance/chomp_spec.rb index 7d2a91b8c..6063e2287 100755 --- a/spec/acceptance/chomp_spec.rb +++ b/spec/acceptance/chomp_spec.rb @@ -3,7 +3,7 @@ describe 'chomp function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $input = "test\n" if size($input) != 5 { fail("Size of ${input} is not 5.") @@ -12,7 +12,7 @@ if size($output) != 4 { fail("Size of ${input} is not 4.") } - EOS + DOC it 'eats the newline' do apply_manifest(pp, :catch_failures => true) end diff --git a/spec/acceptance/chop_spec.rb b/spec/acceptance/chop_spec.rb index 535b8010c..4f4b30c1b 100755 --- a/spec/acceptance/chop_spec.rb +++ b/spec/acceptance/chop_spec.rb @@ -3,7 +3,7 @@ describe 'chop function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $input = "test" if size($input) != 4 { fail("Size of ${input} is not 4.") @@ -12,12 +12,12 @@ if size($output) != 3 { fail("Size of ${input} is not 3.") } - EOS + DOC it 'eats the last character' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-'EOS' + pp2 = <<-'DOC' $input = "test\r\n" if size($input) != 6 { fail("Size of ${input} is not 6.") @@ -26,15 +26,15 @@ if size($output) != 4 { fail("Size of ${input} is not 4.") } - EOS + DOC it 'eats the last two characters of \r\n' do apply_manifest(pp2, :catch_failures => true) end - pp3 = <<-EOS + pp3 = <<-DOC $input = "" $output = chop($input) - EOS + DOC it 'does not fail on empty strings' do apply_manifest(pp3, :catch_failures => true) end diff --git a/spec/acceptance/clamp_spec.rb b/spec/acceptance/clamp_spec.rb index da5860ac2..022bf5ee2 100755 --- a/spec/acceptance/clamp_spec.rb +++ b/spec/acceptance/clamp_spec.rb @@ -3,7 +3,7 @@ describe 'clamp function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $x = 17 $y = 225 $z = 155 @@ -11,21 +11,21 @@ if $o == $z { notify { 'output correct': } } - EOS + DOC it 'clamps list of values' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = [7, 19, 66] $b = 19 $o = clamp($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'clamps array of values' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index 8cecd4d8c..45669bc85 100755 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -3,40 +3,40 @@ describe 'concat function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $output = concat(['1','2','3'],['4','5','6']) validate_array($output) if size($output) != 6 { fail("${output} should have 6 elements.") } - EOS + DOC it 'concats one array to another' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $output = concat(['1','2','3'],'4','5','6',['7','8','9']) validate_array($output) if size($output) != 9 { fail("${output} should have 9 elements.") } - EOS + DOC it 'concats arrays and primitives to array' do apply_manifest(pp2, :catch_failures => true) end - pp3 = <<-EOS + pp3 = <<-DOC $output = concat(['1','2','3'],['4','5','6'],['7','8','9']) validate_array($output) if size($output) != 9 { fail("${output} should have 9 elements.") } - EOS + DOC it 'concats multiple arrays to one' do apply_manifest(pp3, :catch_failures => true) end - pp4 = <<-EOS + pp4 = <<-DOC $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"}) validate_array($output) if size($output) != 2 { @@ -45,7 +45,7 @@ if $output[1] != {"c" => "d", "e" => "f"} { fail("${output} does not have the expected hash for the second element.") } - EOS + DOC it 'concats hash arguments' do apply_manifest(pp4, :catch_failures => true) end diff --git a/spec/acceptance/count_spec.rb b/spec/acceptance/count_spec.rb index a7f780d45..6965ad3f3 100755 --- a/spec/acceptance/count_spec.rb +++ b/spec/acceptance/count_spec.rb @@ -3,22 +3,22 @@ describe 'count function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $input = [1,2,3,4] $output = count($input) notify { "$output": } - EOS + DOC it 'counts elements in an array' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: 4}) end end - pp2 = <<-EOS + pp2 = <<-DOC $input = [1,1,1,2] $output = count($input, 1) notify { "$output": } - EOS + DOC it 'counts elements in an array that match a second argument' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: 3}) diff --git a/spec/acceptance/deep_merge_spec.rb b/spec/acceptance/deep_merge_spec.rb index 060366c9e..0c7517c8d 100755 --- a/spec/acceptance/deep_merge_spec.rb +++ b/spec/acceptance/deep_merge_spec.rb @@ -3,7 +3,7 @@ describe 'deep_merge function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } } $merged_hash = deep_merge($hash1, $hash2) @@ -11,7 +11,7 @@ if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } { fail("Hash was incorrectly merged.") } - EOS + DOC it 'deeps merge two hashes' do apply_manifest(pp, :catch_failures => true) end diff --git a/spec/acceptance/defined_with_params_spec.rb b/spec/acceptance/defined_with_params_spec.rb index 0a27702ec..369c4176b 100755 --- a/spec/acceptance/defined_with_params_spec.rb +++ b/spec/acceptance/defined_with_params_spec.rb @@ -3,7 +3,7 @@ describe 'defined_with_params function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC user { 'dan': ensure => present, } @@ -11,7 +11,7 @@ if defined_with_params(User[dan], {'ensure' => 'present' }) { notify { 'User defined with ensure=>present': } } - EOS + DOC it 'successfullies notify' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: User defined with ensure=>present}) diff --git a/spec/acceptance/delete_at_spec.rb b/spec/acceptance/delete_at_spec.rb index 7bcc9f8a6..1e04964e1 100755 --- a/spec/acceptance/delete_at_spec.rb +++ b/spec/acceptance/delete_at_spec.rb @@ -3,12 +3,12 @@ describe 'delete_at function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $output = delete_at(['a','b','c','b'], 1) if $output == ['a','c','b'] { notify { 'output correct': } } - EOS + DOC it 'deletes elements of the array' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/delete_spec.rb b/spec/acceptance/delete_spec.rb index b349f6148..8a08d938f 100755 --- a/spec/acceptance/delete_spec.rb +++ b/spec/acceptance/delete_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper_acceptance' describe 'delete function' do - pp = <<-EOS + pp = <<-DOC $output = delete(['a','b','c','b'], 'b') if $output == ['a','c'] { notify { 'output correct': } } - EOS + DOC describe 'success' do it 'deletes elements of the array' do apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/delete_undef_values_spec.rb b/spec/acceptance/delete_undef_values_spec.rb index 411905c77..62cc4b808 100755 --- a/spec/acceptance/delete_undef_values_spec.rb +++ b/spec/acceptance/delete_undef_values_spec.rb @@ -3,12 +3,12 @@ describe 'delete_undef_values function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false}) if $output == { a => 'A', b => '', d => false } { notify { 'output correct': } } - EOS + DOC it 'deletes elements of the array' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/delete_values_spec.rb b/spec/acceptance/delete_values_spec.rb index bc8827a94..33f9cc9d0 100755 --- a/spec/acceptance/delete_values_spec.rb +++ b/spec/acceptance/delete_values_spec.rb @@ -3,14 +3,14 @@ describe 'delete_values function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' } $b = { 'a' => 'A', 'B' => 'C' } $o = delete_values($a, 'B') if $o == $b { notify { 'output correct': } } - EOS + DOC it 'deletes elements of the hash' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/difference_spec.rb b/spec/acceptance/difference_spec.rb index a45f6ab74..ee594f1aa 100755 --- a/spec/acceptance/difference_spec.rb +++ b/spec/acceptance/difference_spec.rb @@ -3,7 +3,7 @@ describe 'difference function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ['a','b','c'] $b = ['b','c','d'] $c = ['a'] @@ -11,7 +11,7 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'returns non-duplicates in the first array' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/dirname_spec.rb b/spec/acceptance/dirname_spec.rb index 1e00c5887..a6b534978 100755 --- a/spec/acceptance/dirname_spec.rb +++ b/spec/acceptance/dirname_spec.rb @@ -3,30 +3,30 @@ describe 'dirname function' do describe 'success' do - context 'absolute path' do - pp1 = <<-EOS + context 'with absolute path' do + pp1 = <<-DOC $a = '/path/to/a/file.txt' $b = '/path/to/a' $o = dirname($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'returns the dirname' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end end - context 'relative path' do - pp2 = <<-EOS + context 'with relative path' do + pp2 = <<-DOC $a = 'path/to/a/file.txt' $b = 'path/to/a' $o = dirname($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'returns the dirname' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/downcase_spec.rb b/spec/acceptance/downcase_spec.rb index c3d537bb1..9639e7f24 100755 --- a/spec/acceptance/downcase_spec.rb +++ b/spec/acceptance/downcase_spec.rb @@ -3,28 +3,28 @@ describe 'downcase function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = 'AOEU' $b = 'aoeu' $o = downcase($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'returns the downcase' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = 'aoeu aoeu' $b = 'aoeu aoeu' $o = downcase($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'doesn\'t affect lowercase words' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 3201ba83b..9d6256b2d 100755 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -3,42 +3,42 @@ describe 'empty function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '' $b = true $o = empty($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'recognizes empty strings' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = 'aoeu' $b = false $o = empty($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'recognizes non-empty strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = 7 $b = false $o = empty($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'handles numerical values' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/ensure_resource_spec.rb b/spec/acceptance/ensure_resource_spec.rb index 3b0807192..f310f67da 100755 --- a/spec/acceptance/ensure_resource_spec.rb +++ b/spec/acceptance/ensure_resource_spec.rb @@ -3,19 +3,19 @@ describe 'ensure_resource function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC notify { "test": loglevel => 'err' } ensure_resource('notify', 'test', { 'loglevel' => 'err' }) - EOS + DOC it 'ensures a resource already declared' do apply_manifest('') apply_manifest(pp1, :expect_changes => true) end - pp2 = <<-EOS + pp2 = <<-DOC ensure_resource('notify', 'test', { 'loglevel' => 'err' }) - EOS + DOC it 'ensures a undeclared resource' do apply_manifest('') diff --git a/spec/acceptance/flatten_spec.rb b/spec/acceptance/flatten_spec.rb index cf1a43a39..fca468d77 100755 --- a/spec/acceptance/flatten_spec.rb +++ b/spec/acceptance/flatten_spec.rb @@ -3,28 +3,28 @@ describe 'flatten function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ["a","b",["c",["d","e"],"f","g"]] $b = ["a","b","c","d","e","f","g"] $o = flatten($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'flattens arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = ["a","b","c","d","e","f","g"] $b = ["a","b","c","d","e","f","g"] $o = flatten($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'does not affect flat arrays' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/floor_spec.rb b/spec/acceptance/floor_spec.rb index efe777342..ad2b1f9ce 100755 --- a/spec/acceptance/floor_spec.rb +++ b/spec/acceptance/floor_spec.rb @@ -3,28 +3,28 @@ describe 'floor function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = 12.8 $b = 12 $o = floor($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'floors floats' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = 7 $b = 7 $o = floor($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'floors integers' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/fqdn_rand_string_spec.rb b/spec/acceptance/fqdn_rand_string_spec.rb index a1380093c..4f8b4af8d 100644 --- a/spec/acceptance/fqdn_rand_string_spec.rb +++ b/spec/acceptance/fqdn_rand_string_spec.rb @@ -9,48 +9,48 @@ fake_fact('fqdn', 'fakehost.localdomain') end - pp1 = <<-eos + pp1 = <<-PUPPETCODE $l = 10 $o = fqdn_rand_string($l) notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos + PUPPETCODE it 'generates random alphanumeric strings' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"}) end end - pp2 = <<-eos + pp2 = <<-PUPPETCODE $l = 10 $c = '0123456789' $o = fqdn_rand_string($l, $c) notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos + PUPPETCODE it 'generates random alphanumeric strings with custom charsets' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rand_string is "(7203048515|2383756694)"}) end end - pp3 = <<-eos + pp3 = <<-PUPPETCODE $l = 10 $s = 'seed' $o = fqdn_rand_string($l, undef, $s) notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos + PUPPETCODE it 'generates random alphanumeric strings with custom seeds' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"}) end end - pp4 = <<-eos + pp4 = <<-PUPPETCODE $l = 10 $c = '0123456789' $s = 'seed' $o = fqdn_rand_string($l, $c, $s) notice(inline_template('fqdn_rand_string is <%= @o.inspect %>')) - eos + PUPPETCODE it 'generates random alphanumeric strings with custom charsets and seeds' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rand_string is "(3104058232|7100592312)"}) diff --git a/spec/acceptance/fqdn_rotate_spec.rb b/spec/acceptance/fqdn_rotate_spec.rb index 613ab2ab0..b87b6f0f3 100755 --- a/spec/acceptance/fqdn_rotate_spec.rb +++ b/spec/acceptance/fqdn_rotate_spec.rb @@ -9,46 +9,46 @@ fake_fact('fqdn', 'fakehost.localdomain') end - pp1 = <<-EOS + pp1 = <<-DOC $a = ['a','b','c','d'] $o = fqdn_rotate($a) notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS + DOC it 'rotates arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rotate is \["d", "a", "b", "c"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = ['a','b','c','d'] $s = 'seed' $o = fqdn_rotate($a, $s) notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS + DOC it 'rotates arrays with custom seeds' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rotate is \["c", "d", "a", "b"\]}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = 'abcd' $o = fqdn_rotate($a) notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS + DOC it 'rotates strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rotate is "dabc"}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = 'abcd' $s = 'seed' $o = fqdn_rotate($a, $s) notice(inline_template('fqdn_rotate is <%= @o.inspect %>')) - EOS + DOC it 'rotates strings with custom seeds' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{fqdn_rotate is "cdab"}) diff --git a/spec/acceptance/get_module_path_spec.rb b/spec/acceptance/get_module_path_spec.rb index 6d958f340..828c3fd63 100755 --- a/spec/acceptance/get_module_path_spec.rb +++ b/spec/acceptance/get_module_path_spec.rb @@ -3,7 +3,7 @@ describe 'get_module_path function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = $::is_pe ? { 'true' => '/etc/puppetlabs/puppet/modules/dne', 'false' => '/etc/puppet/modules/dne', @@ -14,7 +14,7 @@ } else { notify { "failed; module path is '$o'": } } - EOS + DOC it 'get_module_paths dne' do apply_manifest(pp, :expect_failures => true) end diff --git a/spec/acceptance/getparam_spec.rb b/spec/acceptance/getparam_spec.rb index 98cd3f597..c5b6ae56e 100755 --- a/spec/acceptance/getparam_spec.rb +++ b/spec/acceptance/getparam_spec.rb @@ -3,13 +3,13 @@ describe 'getparam function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC notify { 'rspec': message => 'custom rspec message', } $o = getparam(Notify['rspec'], 'message') notice(inline_template('getparam is <%= @o.inspect %>')) - EOS + DOC it 'getparam a notify' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{getparam is "custom rspec message"}) diff --git a/spec/acceptance/getvar_spec.rb b/spec/acceptance/getvar_spec.rb index cccf59d1e..212108537 100755 --- a/spec/acceptance/getvar_spec.rb +++ b/spec/acceptance/getvar_spec.rb @@ -3,7 +3,7 @@ describe 'getvar function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC class a::data { $foo = 'aoeu' } include a::data $b = 'aoeu' @@ -11,7 +11,7 @@ class a::data { $foo = 'aoeu' } if $o == $b { notify { 'output correct': } } - EOS + DOC it 'getvars from classes' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/grep_spec.rb b/spec/acceptance/grep_spec.rb index f4e69c141..504acdaa9 100755 --- a/spec/acceptance/grep_spec.rb +++ b/spec/acceptance/grep_spec.rb @@ -3,7 +3,7 @@ describe 'grep function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ['aaabbb','bbbccc','dddeee'] $b = 'bbb' $c = ['aaabbb','bbbccc'] @@ -11,7 +11,7 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'greps arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/has_interface_with_spec.rb b/spec/acceptance/has_interface_with_spec.rb index 617df8f02..7e779b7e1 100755 --- a/spec/acceptance/has_interface_with_spec.rb +++ b/spec/acceptance/has_interface_with_spec.rb @@ -3,29 +3,29 @@ describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = $::ipaddress $o = has_interface_with('ipaddress', $a) notice(inline_template('has_interface_with is <%= @o.inspect %>')) - EOS + DOC it 'has_interface_with existing ipaddress' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_interface_with is true}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = '128.0.0.1' $o = has_interface_with('ipaddress', $a) notice(inline_template('has_interface_with is <%= @o.inspect %>')) - EOS + DOC it 'has_interface_with absent ipaddress' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_interface_with is false}) end end - pp3 = <<-EOS + pp3 = <<-DOC if $osfamily == 'Solaris' or $osfamily == 'Darwin' { $a = 'lo0' }elsif $osfamily == 'windows' { @@ -39,7 +39,7 @@ } $o = has_interface_with($a) notice(inline_template('has_interface_with is <%= @o.inspect %>')) - EOS + DOC it 'has_interface_with existing interface' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_interface_with is true}) diff --git a/spec/acceptance/has_ip_address_spec.rb b/spec/acceptance/has_ip_address_spec.rb index 84d2089b5..32f86d20c 100755 --- a/spec/acceptance/has_ip_address_spec.rb +++ b/spec/acceptance/has_ip_address_spec.rb @@ -3,22 +3,22 @@ describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '127.0.0.1' $o = has_ip_address($a) notice(inline_template('has_ip_address is <%= @o.inspect %>')) - EOS + DOC it 'has_ip_address existing ipaddress' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_ip_address is true}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = '128.0.0.1' $o = has_ip_address($a) notice(inline_template('has_ip_address is <%= @o.inspect %>')) - EOS + DOC it 'has_ip_address absent ipaddress' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_ip_address is false}) diff --git a/spec/acceptance/has_ip_network_spec.rb b/spec/acceptance/has_ip_network_spec.rb index 6ce533c79..b34e326b9 100755 --- a/spec/acceptance/has_ip_network_spec.rb +++ b/spec/acceptance/has_ip_network_spec.rb @@ -3,22 +3,22 @@ describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '127.0.0.0' $o = has_ip_network($a) notice(inline_template('has_ip_network is <%= @o.inspect %>')) - EOS + DOC it 'has_ip_network existing ipaddress' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_ip_network is true}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = '128.0.0.0' $o = has_ip_network($a) notice(inline_template('has_ip_network is <%= @o.inspect %>')) - EOS + DOC it 'has_ip_network absent ipaddress' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{has_ip_network is false}) diff --git a/spec/acceptance/has_key_spec.rb b/spec/acceptance/has_key_spec.rb index 6f41c63e7..9731a0e93 100755 --- a/spec/acceptance/has_key_spec.rb +++ b/spec/acceptance/has_key_spec.rb @@ -3,7 +3,7 @@ describe 'has_key function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' } $b = 'bbb' $c = true @@ -11,14 +11,14 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'has_keys in hashes' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' } $b = 'ccc' $c = false @@ -26,7 +26,7 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'has_keys not in hashes' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/hash_spec.rb b/spec/acceptance/hash_spec.rb index f07945649..20287d2f7 100755 --- a/spec/acceptance/hash_spec.rb +++ b/spec/acceptance/hash_spec.rb @@ -3,14 +3,14 @@ describe 'hash function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ['aaa','bbb','bbb','ccc','ddd','eee'] $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' } $o = hash($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'hashs arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/intersection_spec.rb b/spec/acceptance/intersection_spec.rb index a5c2b3b4c..9775937b5 100755 --- a/spec/acceptance/intersection_spec.rb +++ b/spec/acceptance/intersection_spec.rb @@ -3,7 +3,7 @@ describe 'intersection function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ['aaa','bbb','ccc'] $b = ['bbb','ccc','ddd','eee'] $c = ['bbb','ccc'] @@ -11,7 +11,7 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'intersections arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_a_spec.rb b/spec/acceptance/is_a_spec.rb index defdc2413..f2a4972cd 100644 --- a/spec/acceptance/is_a_spec.rb +++ b/spec/acceptance/is_a_spec.rb @@ -3,22 +3,22 @@ if return_puppet_version =~ %r{^4} describe 'is_a function' do - pp1 = <<-EOS + pp1 = <<-DOC if 'hello world'.is_a(String) { notify { 'output correct': } } - EOS + DOC it 'matches a string' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC if 5.is_a(String) { notify { 'output wrong': } } - EOS + DOC it 'does not match a integer as string' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).not_to match(%r{Notice: output wrong}) diff --git a/spec/acceptance/is_array_spec.rb b/spec/acceptance/is_array_spec.rb index 202809358..1d061eb2d 100755 --- a/spec/acceptance/is_array_spec.rb +++ b/spec/acceptance/is_array_spec.rb @@ -3,56 +3,56 @@ describe 'is_array function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa','bbb','ccc'] $b = true $o = is_array($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_arrays arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = [] $b = true $o = is_array($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_arrays empty arrays' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "aoeu" $b = false $o = is_array($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_arrays strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = {'aaa'=>'bbb'} $b = false $o = is_array($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_arrays hashes' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_bool_spec.rb b/spec/acceptance/is_bool_spec.rb index aaad0d530..5f948e48e 100755 --- a/spec/acceptance/is_bool_spec.rb +++ b/spec/acceptance/is_bool_spec.rb @@ -3,70 +3,70 @@ describe 'is_bool function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa','bbb','ccc'] $b = false $o = is_bool($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_bools arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $b = true $o = is_bool($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_bools true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = false $b = true $o = is_bool($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_bools false' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = "true" $b = false $o = is_bool($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_bools strings' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = {'aaa'=>'bbb'} $b = false $o = is_bool($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_bools hashes' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_domain_name_spec.rb b/spec/acceptance/is_domain_name_spec.rb index 249ef1027..498e5c84e 100755 --- a/spec/acceptance/is_domain_name_spec.rb +++ b/spec/acceptance/is_domain_name_spec.rb @@ -3,72 +3,72 @@ describe 'is_domain_name function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa.com','bbb','ccc'] $o = is_domain_name($a) notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS + DOC it 'is_domain_names arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_domain_name is false}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $o = is_domain_name($a) notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS + DOC it 'is_domain_names true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_domain_name is false}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = false $o = is_domain_name($a) notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS + DOC it 'is_domain_names false' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_domain_name is false}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = "3foo-bar.2bar-fuzz.com" $b = true $o = is_domain_name($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_domain_names strings with hyphens' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = "-bar.2bar-fuzz.com" $b = false $o = is_domain_name($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_domain_names strings beginning with hyphens' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp6 = <<-EOS + pp6 = <<-DOC $a = {'aaa'=>'www.com'} $o = is_domain_name($a) notice(inline_template('is_domain_name is <%= @o.inspect %>')) - EOS + DOC it 'is_domain_names hashes' do apply_manifest(pp6, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_domain_name is false}) diff --git a/spec/acceptance/is_float_spec.rb b/spec/acceptance/is_float_spec.rb index 7656027bb..bd1556686 100755 --- a/spec/acceptance/is_float_spec.rb +++ b/spec/acceptance/is_float_spec.rb @@ -3,75 +3,75 @@ describe 'is_float function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa.com','bbb','ccc'] $o = is_float($a) notice(inline_template('is_float is <%= @o.inspect %>')) - EOS + DOC it 'is_floats arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_float is false}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $o = is_float($a) notice(inline_template('is_float is <%= @o.inspect %>')) - EOS + DOC it 'is_floats true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_float is false}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "3.5" $b = true $o = is_float($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_floats strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = 3.5 $b = true $o = is_float($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_floats floats' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = 3 $b = false $o = is_float($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_floats integers' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp6 = <<-EOS + pp6 = <<-DOC $a = {'aaa'=>'www.com'} $o = is_float($a) notice(inline_template('is_float is <%= @o.inspect %>')) - EOS + DOC it 'is_floats hashes' do apply_manifest(pp6, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_float is false}) diff --git a/spec/acceptance/is_function_available_spec.rb b/spec/acceptance/is_function_available_spec.rb index 4b939223e..db83aa492 100755 --- a/spec/acceptance/is_function_available_spec.rb +++ b/spec/acceptance/is_function_available_spec.rb @@ -3,47 +3,47 @@ describe 'is_function_available function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['fail','include','require'] $o = is_function_available($a) notice(inline_template('is_function_available is <%= @o.inspect %>')) - EOS + DOC it 'is_function_availables arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_function_available is false}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $o = is_function_available($a) notice(inline_template('is_function_available is <%= @o.inspect %>')) - EOS + DOC it 'is_function_availables true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_function_available is false}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "fail" $b = true $o = is_function_available($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_function_availables strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = "is_function_available" $o = is_function_available($a) notice(inline_template('is_function_available is <%= @o.inspect %>')) - EOS + DOC it 'is_function_availables function_availables' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_function_available is true}) diff --git a/spec/acceptance/is_hash_spec.rb b/spec/acceptance/is_hash_spec.rb index 35ea61053..a64577bf3 100755 --- a/spec/acceptance/is_hash_spec.rb +++ b/spec/acceptance/is_hash_spec.rb @@ -3,53 +3,53 @@ describe 'is_hash function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa','bbb','ccc'] $o = is_hash($a) notice(inline_template('is_hash is <%= @o.inspect %>')) - EOS + DOC it 'is_hashs arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_hash is false}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = {} $b = true $o = is_hash($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_hashs empty hashs' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "aoeu" $b = false $o = is_hash($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_hashs strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = {'aaa'=>'bbb'} $b = true $o = is_hash($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_hashs hashes' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_integer_spec.rb b/spec/acceptance/is_integer_spec.rb index 4b1754863..103b76cd0 100755 --- a/spec/acceptance/is_integer_spec.rb +++ b/spec/acceptance/is_integer_spec.rb @@ -3,84 +3,84 @@ describe 'is_integer function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa.com','bbb','ccc'] $b = false $o = is_integer($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_integers arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $b = false $o = is_integer($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_integers true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "3" $b = true $o = is_integer($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_integers strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = 3.5 $b = false $o = is_integer($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_integers floats' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = 3 $b = true $o = is_integer($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_integers integers' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp6 = <<-EOS + pp6 = <<-DOC $a = {'aaa'=>'www.com'} $b = false $o = is_integer($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_integers hashes' do apply_manifest(pp6, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_ip_address_spec.rb b/spec/acceptance/is_ip_address_spec.rb index 3316e56d8..0d8b65888 100755 --- a/spec/acceptance/is_ip_address_spec.rb +++ b/spec/acceptance/is_ip_address_spec.rb @@ -3,70 +3,70 @@ describe 'is_ip_address function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '1.2.3.4' $b = true $o = is_ip_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ip_addresss ipv4' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74" $b = true $o = is_ip_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ip_addresss ipv6' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "fe00::1" $b = true $o = is_ip_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ip_addresss ipv6 compressed' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = "aoeu" $b = false $o = is_ip_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ip_addresss strings' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = '1.2.3.400' $b = false $o = is_ip_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ip_addresss ipv4 out of range' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_ipv4_address_spec.rb b/spec/acceptance/is_ipv4_address_spec.rb index f24050411..de731dd36 100755 --- a/spec/acceptance/is_ipv4_address_spec.rb +++ b/spec/acceptance/is_ipv4_address_spec.rb @@ -3,42 +3,42 @@ describe 'is_ipv4_address function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '1.2.3.4' $b = true $o = is_ipv4_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv4_addresss' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "aoeu" $b = false $o = is_ipv4_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv4_addresss strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = '1.2.3.400' $b = false $o = is_ipv4_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv4_addresss ipv4 out of range' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_ipv6_address_spec.rb b/spec/acceptance/is_ipv6_address_spec.rb index c765d59c6..86dbe97e0 100755 --- a/spec/acceptance/is_ipv6_address_spec.rb +++ b/spec/acceptance/is_ipv6_address_spec.rb @@ -3,56 +3,56 @@ describe 'is_ipv6_address function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74" $b = true $o = is_ipv6_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv6_addresss' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "fe00::1" $b = true $o = is_ipv6_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv6_addresss ipv6 compressed' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "aoeu" $b = false $o = is_ipv6_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv6_addresss strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg' $b = false $o = is_ipv6_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_ipv6_addresss ip out of range' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_mac_address_spec.rb b/spec/acceptance/is_mac_address_spec.rb index 2d70cd935..a50d924dc 100755 --- a/spec/acceptance/is_mac_address_spec.rb +++ b/spec/acceptance/is_mac_address_spec.rb @@ -3,28 +3,28 @@ describe 'is_mac_address function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '00:a0:1f:12:7f:a0' $b = true $o = is_mac_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_mac_addresss a mac' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = '00:a0:1f:12:7f:g0' $b = false $o = is_mac_address($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_mac_addresss a mac out of range' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_numeric_spec.rb b/spec/acceptance/is_numeric_spec.rb index 2c40698ff..5fbc13459 100755 --- a/spec/acceptance/is_numeric_spec.rb +++ b/spec/acceptance/is_numeric_spec.rb @@ -3,84 +3,84 @@ describe 'is_numeric function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa.com','bbb','ccc'] $b = false $o = is_numeric($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_numerics arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $b = false $o = is_numeric($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_numerics true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "3" $b = true $o = is_numeric($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_numerics strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = 3.5 $b = true $o = is_numeric($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_numerics floats' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = 3 $b = true $o = is_numeric($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_numerics integers' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp6 = <<-EOS + pp6 = <<-DOC $a = {'aaa'=>'www.com'} $b = false $o = is_numeric($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_numerics hashes' do apply_manifest(pp6, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/is_string_spec.rb b/spec/acceptance/is_string_spec.rb index 7451f45bd..5d6a9dbe9 100755 --- a/spec/acceptance/is_string_spec.rb +++ b/spec/acceptance/is_string_spec.rb @@ -3,103 +3,103 @@ describe 'is_string function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa.com','bbb','ccc'] $b = false $o = is_string($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_strings arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = true $b = false $o = is_string($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_strings true' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "aoeu" $o = is_string($a) notice(inline_template('is_string is <%= @o.inspect %>')) - EOS + DOC it 'is_strings strings' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_string is true}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = "3" $o = is_string($a) notice(inline_template('is_string is <%= @o.inspect %>')) - EOS + DOC it 'is_strings number strings' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_string is false}) end end - pp5 = <<-EOS + pp5 = <<-DOC $a = 3.5 $b = false $o = is_string($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_strings floats' do apply_manifest(pp5, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp6 = <<-EOS + pp6 = <<-DOC $a = 3 $b = false $o = is_string($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_strings integers' do apply_manifest(pp6, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp7 = <<-EOS + pp7 = <<-DOC $a = {'aaa'=>'www.com'} $b = false $o = is_string($a) if $o == $b { notify { 'output correct': } } - EOS + DOC it 'is_strings hashes' do apply_manifest(pp7, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) end end - pp8 = <<-EOS + pp8 = <<-DOC $a = undef $o = is_string($a) notice(inline_template('is_string is <%= @o.inspect %>')) - EOS + DOC it 'is_strings undef' do apply_manifest(pp8, :catch_failures => true) do |r| expect(r.stdout).to match(%r{is_string is true}) diff --git a/spec/acceptance/join_keys_to_values_spec.rb b/spec/acceptance/join_keys_to_values_spec.rb index 46bf61785..6824736f1 100755 --- a/spec/acceptance/join_keys_to_values_spec.rb +++ b/spec/acceptance/join_keys_to_values_spec.rb @@ -3,12 +3,12 @@ describe 'join_keys_to_values function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = {'aaa'=>'bbb','ccc'=>'ddd'} $b = ':' $o = join_keys_to_values($a,$b) notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>')) - EOS + DOC it 'join_keys_to_valuess hashes' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]}) diff --git a/spec/acceptance/join_spec.rb b/spec/acceptance/join_spec.rb index 6bd0cbce4..32d508423 100755 --- a/spec/acceptance/join_spec.rb +++ b/spec/acceptance/join_spec.rb @@ -3,7 +3,7 @@ describe 'join function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ['aaa','bbb','ccc'] $b = ':' $c = 'aaa:bbb:ccc' @@ -11,7 +11,7 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'joins arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) diff --git a/spec/acceptance/keys_spec.rb b/spec/acceptance/keys_spec.rb index 332e368d8..598e821d1 100755 --- a/spec/acceptance/keys_spec.rb +++ b/spec/acceptance/keys_spec.rb @@ -3,11 +3,11 @@ describe 'keys function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = {'aaa'=>'bbb','ccc'=>'ddd'} $o = keys($a) notice(inline_template('keys is <%= @o.sort.inspect %>')) - EOS + DOC it 'keyss hashes' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{keys is \["aaa", "ccc"\]}) diff --git a/spec/acceptance/loadjson_spec.rb b/spec/acceptance/loadjson_spec.rb index 5aaaeff1d..428bc6b7e 100644 --- a/spec/acceptance/loadjson_spec.rb +++ b/spec/acceptance/loadjson_spec.rb @@ -6,13 +6,13 @@ describe 'loadjson function' do describe 'success' do shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/test1json.json") - pp1 = <<-EOS + pp1 = <<-DOC $o = loadjson('#{tmpdir}/test1json.json') notice(inline_template('loadjson[aaa] is <%= @o["aaa"].inspect %>')) notice(inline_template('loadjson[bbb] is <%= @o["bbb"].inspect %>')) notice(inline_template('loadjson[ccc] is <%= @o["ccc"].inspect %>')) notice(inline_template('loadjson[ddd] is <%= @o["ddd"].inspect %>')) - EOS + DOC regex_array = [%r{loadjson\[aaa\] is 1}, %r{loadjson\[bbb\] is 2}, %r{loadjson\[ccc\] is 3}, %r{loadjson\[ddd\] is 4}] it 'loadjsons array of values' do apply_manifest(pp1, :catch_failures => true) do |r| @@ -22,10 +22,10 @@ end end - pp2 = <<-EOS + pp2 = <<-DOC $o = loadjson('#{tmpdir}/no-file.json', {'default' => 'value'}) notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>')) - EOS + DOC it 'returns the default value if there is no file to load' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{loadjson\[default\] is "value"}) @@ -33,10 +33,10 @@ end shell("echo '!' > #{tmpdir}/test2json.json") - pp3 = <<-EOS + pp3 = <<-DOC $o = loadjson('#{tmpdir}/test2json.json', {'default' => 'value'}) notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>')) - EOS + DOC it 'returns the default value if the file was parsed with an error' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{loadjson\[default\] is "value"}) diff --git a/spec/acceptance/loadyaml_spec.rb b/spec/acceptance/loadyaml_spec.rb index 96cafc772..7ec461fb0 100644 --- a/spec/acceptance/loadyaml_spec.rb +++ b/spec/acceptance/loadyaml_spec.rb @@ -10,13 +10,13 @@ bbb: 2 ccc: 3 ddd: 4' > #{tmpdir}/test1yaml.yaml") - pp1 = <<-EOS + pp1 = <<-DOC $o = loadyaml('#{tmpdir}/test1yaml.yaml') notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>')) notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>')) notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>')) notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>')) - EOS + DOC regex_array = [%r{loadyaml\[aaa\] is 1}, %r{loadyaml\[bbb\] is 2}, %r{loadyaml\[ccc\] is 3}, %r{loadyaml\[ddd\] is 4}] it 'loadyamls array of values' do apply_manifest(pp1, :catch_failures => true) do |r| @@ -26,10 +26,10 @@ end end - pp2 = <<-EOS + pp2 = <<-DOC $o = loadyaml('#{tmpdir}/no-file.yaml', {'default' => 'value'}) notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>')) - EOS + DOC it 'returns the default value if there is no file to load' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{loadyaml\[default\] is "value"}) @@ -37,10 +37,10 @@ end shell("echo '!' > #{tmpdir}/test2yaml.yaml") - pp3 = <<-EOS + pp3 = <<-DOC $o = loadyaml('#{tmpdir}/test2yaml.yaml', {'default' => 'value'}) notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>')) - EOS + DOC it 'returns the default value if the file was parsed with an error' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{loadyaml\[default\] is "value"}) diff --git a/spec/acceptance/lstrip_spec.rb b/spec/acceptance/lstrip_spec.rb index a7fe8da92..1803dd1cd 100755 --- a/spec/acceptance/lstrip_spec.rb +++ b/spec/acceptance/lstrip_spec.rb @@ -3,23 +3,23 @@ describe 'lstrip function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = [" the "," public "," art","galleries "] # Anagram: Large picture halls, I bet $o = lstrip($a) notice(inline_template('lstrip is <%= @o.inspect %>')) - EOS + DOC it 'lstrips arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{lstrip is \["the ", "public ", "art", "galleries "\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = " blowzy night-frumps vex'd jack q " $o = lstrip($a) notice(inline_template('lstrip is <%= @o.inspect %>')) - EOS + DOC it 'lstrips strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{lstrip is "blowzy night-frumps vex'd jack q "}) diff --git a/spec/acceptance/max_spec.rb b/spec/acceptance/max_spec.rb index c1cf67137..240ce344b 100755 --- a/spec/acceptance/max_spec.rb +++ b/spec/acceptance/max_spec.rb @@ -3,10 +3,10 @@ describe 'max function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = max("the","public","art","galleries") notice(inline_template('max is <%= @o.inspect %>')) - EOS + DOC it 'maxs arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{max is "the"}) diff --git a/spec/acceptance/member_spec.rb b/spec/acceptance/member_spec.rb index ee8f2b233..6effbde0c 100755 --- a/spec/acceptance/member_spec.rb +++ b/spec/acceptance/member_spec.rb @@ -10,7 +10,7 @@ end end describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ['aaa','bbb','ccc'] $b = 'ccc' $c = true @@ -18,7 +18,7 @@ if $o == $c { notify { 'output correct': } } - EOS + DOC it 'members arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{Notice: output correct}) @@ -27,23 +27,23 @@ describe 'members array of integers' do it_behaves_like 'item found' do - let(:pp) do # rubocop:disable RSpec/LetBeforeExamples : 'let' required to be inside example for it to work - <<-EOS + let(:pp) do + <<-DOC if member( [1,2,3,4], 4 ){ notify { 'output correct': } } - EOS + DOC end end end describe 'members of mixed array' do it_behaves_like 'item found' do - let(:pp) do # rubocop:disable RSpec/LetBeforeExamples : 'let' required to be inside example for it to work - <<-EOS + let(:pp) do + <<-DOC if member( ['a','4',3], 'a' ){ notify { 'output correct': } } - EOS + DOC end end end diff --git a/spec/acceptance/merge_spec.rb b/spec/acceptance/merge_spec.rb index 1528ad949..ea7ae897d 100755 --- a/spec/acceptance/merge_spec.rb +++ b/spec/acceptance/merge_spec.rb @@ -3,14 +3,14 @@ describe 'merge function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } } $b = {'two' => 'dos', 'three' => { 'five' => 5 } } $o = merge($a, $b) notice(inline_template('merge[one] is <%= @o["one"].inspect %>')) notice(inline_template('merge[two] is <%= @o["two"].inspect %>')) notice(inline_template('merge[three] is <%= @o["three"].inspect %>')) - EOS + DOC regex_array = [%r{merge\[one\] is ("1"|1)}, %r{merge\[two\] is "dos"}, %r{merge\[three\] is {"five"=>("5"|5)}}] it 'merges two hashes' do apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/min_spec.rb b/spec/acceptance/min_spec.rb index f011c64e4..443c3cc47 100755 --- a/spec/acceptance/min_spec.rb +++ b/spec/acceptance/min_spec.rb @@ -3,10 +3,10 @@ describe 'min function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = min("the","public","art","galleries") notice(inline_template('min is <%= @o.inspect %>')) - EOS + DOC it 'mins arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{min is "art"}) diff --git a/spec/acceptance/num2bool_spec.rb b/spec/acceptance/num2bool_spec.rb index 24f95dfcc..6e8707d5a 100755 --- a/spec/acceptance/num2bool_spec.rb +++ b/spec/acceptance/num2bool_spec.rb @@ -3,7 +3,7 @@ describe 'num2bool function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = 1 $b = "1" $c = "50" @@ -13,7 +13,7 @@ notice(inline_template('a is <%= @ao.inspect %>')) notice(inline_template('b is <%= @bo.inspect %>')) notice(inline_template('c is <%= @co.inspect %>')) - EOS + DOC regex_array_true = [%r{a is true}, %r{b is true}, %r{c is true}] it 'bools positive numbers and numeric strings as true' do apply_manifest(pp1, :catch_failures => true) do |r| @@ -23,7 +23,7 @@ end end - pp2 = <<-EOS + pp2 = <<-DOC $a = 0 $b = -0.1 $c = ["-50","1"] @@ -33,7 +33,7 @@ notice(inline_template('a is <%= @ao.inspect %>')) notice(inline_template('b is <%= @bo.inspect %>')) notice(inline_template('c is <%= @co.inspect %>')) - EOS + DOC regex_array_false = [%r{a is false}, %r{b is false}, %r{c is false}] it 'bools negative numbers as false' do apply_manifest(pp2, :catch_failures => true) do |r| @@ -45,29 +45,29 @@ end describe 'failure' do - pp3 = <<-EOS + pp3 = <<-DOC $a = "a" $ao = num2bool($a) notice(inline_template('a is <%= @ao.inspect %>')) - EOS + DOC it 'fails on words' do expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{not look like a number}) end - pp4 = <<-EOS + pp4 = <<-DOC $b = "1b" $bo = num2bool($b) notice(inline_template('b is <%= @bo.inspect %>')) - EOS + DOC it 'fails on numberwords' do expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{not look like a number}) end - pp5 = <<-EOS # rubocop:disable Lint/UselessAssignment + pp5 = <<-DOC # rubocop:disable Lint/UselessAssignment $c = {"c" => "-50"} $co = num2bool($c) notice(inline_template('c is <%= @co.inspect %>')) - EOS + DOC it 'fails on non-numeric/strings' do pending "The function will call .to_s.to_i on anything not a Numeric or String, and results in 0. Is this intended?" diff --git a/spec/acceptance/parsejson_spec.rb b/spec/acceptance/parsejson_spec.rb index 109936981..3d81cfa60 100755 --- a/spec/acceptance/parsejson_spec.rb +++ b/spec/acceptance/parsejson_spec.rb @@ -3,12 +3,12 @@ describe 'parsejson function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = '{"hunter": "washere", "tests": "passing"}' $ao = parsejson($a) $tests = $ao['tests'] notice(inline_template('tests are <%= @tests.inspect %>')) - EOS + DOC it 'parses valid json' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{tests are "passing"}) @@ -17,31 +17,31 @@ end describe 'failure' do - pp2 = <<-EOS + pp2 = <<-DOC $a = '{"hunter": "washere", "tests": "passing",}' $ao = parsejson($a, 'tests are using the default value') notice(inline_template('a is <%= @ao.inspect %>')) - EOS + DOC it 'raises error on incorrect json - default value is used' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{tests are using the default value}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = '{"hunter": "washere", "tests": "passing",}' $ao = parsejson($a) notice(inline_template('a is <%= @ao.inspect %>')) - EOS + DOC it 'raises error on incorrect json' do apply_manifest(pp3, :expect_failures => true) do |r| expect(r.stderr).to match(%r{expected next name}) end end - pp4 = <<-EOS + pp4 = <<-DOC $o = parsejson() - EOS + DOC it 'raises error on incorrect number of arguments' do apply_manifest(pp4, :expect_failures => true) do |r| expect(r.stderr).to match(%r{wrong number of arguments}i) diff --git a/spec/acceptance/parseyaml_spec.rb b/spec/acceptance/parseyaml_spec.rb index 329eccf39..1b24e004b 100755 --- a/spec/acceptance/parseyaml_spec.rb +++ b/spec/acceptance/parseyaml_spec.rb @@ -3,12 +3,12 @@ describe 'parseyaml function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = "---\nhunter: washere\ntests: passing\n" $o = parseyaml($a) $tests = $o['tests'] notice(inline_template('tests are <%= @tests.inspect %>')) - EOS + DOC it 'parses valid yaml' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{tests are "passing"}) @@ -17,33 +17,33 @@ end describe 'failure' do - pp2 = <<-EOS + pp2 = <<-DOC $a = "---\nhunter: washere\ntests: passing\n:" $o = parseyaml($a, {'tests' => 'using the default value'}) $tests = $o['tests'] notice(inline_template('tests are <%= @tests.inspect %>')) - EOS + DOC it 'returns the default value on incorrect yaml' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{tests are "using the default value"}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "---\nhunter: washere\ntests: passing\n:" $o = parseyaml($a) $tests = $o['tests'] notice(inline_template('tests are <%= @tests.inspect %>')) - EOS + DOC it 'raises error on incorrect yaml' do apply_manifest(pp3, :expect_failures => true) do |r| expect(r.stderr).to match(%r{(syntax error|did not find expected key)}) end end - pp4 = <<-EOS + pp4 = <<-DOC $o = parseyaml() - EOS + DOC it 'raises error on incorrect number of arguments' do apply_manifest(pp4, :expect_failures => true) do |r| expect(r.stderr).to match(%r{wrong number of arguments}i) diff --git a/spec/acceptance/pick_default_spec.rb b/spec/acceptance/pick_default_spec.rb index b641fe6b4..7047e239f 100755 --- a/spec/acceptance/pick_default_spec.rb +++ b/spec/acceptance/pick_default_spec.rb @@ -3,35 +3,35 @@ describe 'pick_default function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = undef $o = pick_default($a, 'default') notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'pick_defaults a default value' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{picked is "default"}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = undef $b = undef $o = pick_default($a,$b) notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'pick_defaults with no value' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{picked is ""}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "something" $b = "long" $o = pick_default($a, $b, 'default') notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'pick_defaults the first set value' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{picked is "something"}) @@ -39,10 +39,10 @@ end end describe 'failure' do - pp4 = <<-EOS + pp4 = <<-DOC $o = pick_default() notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'raises error with no values' do apply_manifest(pp4, :expect_failures => true) do |r| expect(r.stderr).to match(%r{Must receive at least one argument}) diff --git a/spec/acceptance/pick_spec.rb b/spec/acceptance/pick_spec.rb index 06a6269fa..e25a9bef5 100755 --- a/spec/acceptance/pick_spec.rb +++ b/spec/acceptance/pick_spec.rb @@ -3,23 +3,23 @@ describe 'pick function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = undef $o = pick($a, 'default') notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'picks a default value' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{picked is "default"}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "something" $b = "long" $o = pick($a, $b, 'default') notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'picks the first set value' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{picked is "something"}) @@ -28,12 +28,12 @@ end describe 'failure' do - pp3 = <<-EOS + pp3 = <<-DOC $a = undef $b = undef $o = pick($a, $b) notice(inline_template('picked is <%= @o.inspect %>')) - EOS + DOC it 'raises error with all undef values' do apply_manifest(pp3, :expect_failures => true) do |r| expect(r.stderr).to match(%r{must receive at least one non empty value}) diff --git a/spec/acceptance/prefix_spec.rb b/spec/acceptance/prefix_spec.rb index 9b09b1541..b4be38344 100755 --- a/spec/acceptance/prefix_spec.rb +++ b/spec/acceptance/prefix_spec.rb @@ -3,30 +3,30 @@ describe 'prefix function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $o = prefix(['a','b','c'],'p') notice(inline_template('prefix is <%= @o.inspect %>')) - EOS + DOC it 'prefixes array of values' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{prefix is \["pa", "pb", "pc"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $o = prefix([],'p') notice(inline_template('prefix is <%= @o.inspect %>')) - EOS + DOC it 'prefixs with empty array' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{prefix is \[\]}) end end - pp3 = <<-EOS + pp3 = <<-DOC $o = prefix(['a','b','c'], undef) notice(inline_template('prefix is <%= @o.inspect %>')) - EOS + DOC it 'prefixs array of values with undef' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{prefix is \["a", "b", "c"\]}) diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb index 4e365a133..0c24bb9bb 100644 --- a/spec/acceptance/pw_hash_spec.rb +++ b/spec/acceptance/pw_hash_spec.rb @@ -4,20 +4,20 @@ # Windows and OS X do not have useful implementations of crypt(3) describe 'pw_hash function', :unless => %w[windows Darwin SLES].include?(fact('operatingsystem')) do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $o = pw_hash('password', 'sha-512', 'salt') notice(inline_template('pw_hash is <%= @o.inspect %>')) - EOS + DOC it 'hashes passwords' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."}) end end - pp2 = <<-EOS + pp2 = <<-DOC $o = pw_hash('', 'sha-512', 'salt') notice(inline_template('pw_hash is <%= @o.inspect %>')) - EOS + DOC it 'returns nil if no password is provided' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{pw_hash is nil}) diff --git a/spec/acceptance/range_spec.rb b/spec/acceptance/range_spec.rb index 2783cc8bb..abdaaf05c 100755 --- a/spec/acceptance/range_spec.rb +++ b/spec/acceptance/range_spec.rb @@ -3,20 +3,20 @@ describe 'range function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $o = range('a','d') notice(inline_template('range is <%= @o.inspect %>')) - EOS + DOC it 'ranges letters' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{range is \["a", "b", "c", "d"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $o = range('a','d', '2') notice(inline_template('range is <%= @o.inspect %>')) - EOS + DOC it 'ranges letters with a step' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{range is \["a", "c"\]}) diff --git a/spec/acceptance/reject_spec.rb b/spec/acceptance/reject_spec.rb index 6b16c07f8..b25983be5 100755 --- a/spec/acceptance/reject_spec.rb +++ b/spec/acceptance/reject_spec.rb @@ -3,30 +3,30 @@ describe 'reject function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa') notice(inline_template('reject is <%= @o.inspect %>')) - EOS + DOC it 'rejects array of values' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{reject is \["bbb", "ccc"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $o = reject([],'aaa') notice(inline_template('reject is <%= @o.inspect %>')) - EOS + DOC it 'rejects with empty array' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{reject is \[\]}) end end - pp3 = <<-EOS + pp3 = <<-DOC $o = reject(['aaa','bbb','ccc','aaaddd'], undef) notice(inline_template('reject is <%= @o.inspect %>')) - EOS + DOC it 'rejects array of values with undef' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{reject is \[\]}) diff --git a/spec/acceptance/reverse_spec.rb b/spec/acceptance/reverse_spec.rb index 18e2d238f..f94b5ea51 100755 --- a/spec/acceptance/reverse_spec.rb +++ b/spec/acceptance/reverse_spec.rb @@ -3,12 +3,12 @@ describe 'reverse function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = "the public art galleries" # Anagram: Large picture halls, I bet $o = reverse($a) notice(inline_template('reverse is <%= @o.inspect %>')) - EOS + DOC it 'reverses strings' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{reverse is "seirellag tra cilbup eht"}) diff --git a/spec/acceptance/rstrip_spec.rb b/spec/acceptance/rstrip_spec.rb index 335bcdc36..b2c0209f6 100755 --- a/spec/acceptance/rstrip_spec.rb +++ b/spec/acceptance/rstrip_spec.rb @@ -3,23 +3,23 @@ describe 'rstrip function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = [" the "," public "," art","galleries "] # Anagram: Large picture halls, I bet $o = rstrip($a) notice(inline_template('rstrip is <%= @o.inspect %>')) - EOS + DOC it 'rstrips arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{rstrip is \[" the", " public", " art", "galleries"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = " blowzy night-frumps vex'd jack q " $o = rstrip($a) notice(inline_template('rstrip is <%= @o.inspect %>')) - EOS + DOC it 'rstrips strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{rstrip is " blowzy night-frumps vex'd jack q"}) diff --git a/spec/acceptance/shuffle_spec.rb b/spec/acceptance/shuffle_spec.rb index e561b26aa..f12e04f08 100755 --- a/spec/acceptance/shuffle_spec.rb +++ b/spec/acceptance/shuffle_spec.rb @@ -3,23 +3,23 @@ describe 'shuffle function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"] # Anagram: Large picture halls, I bet $o = shuffle($a) notice(inline_template('shuffle is <%= @o.inspect %>')) - EOS + DOC it 'shuffles arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).not_to match(%r{shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "blowzy night-frumps vex'd jack q" $o = shuffle($a) notice(inline_template('shuffle is <%= @o.inspect %>')) - EOS + DOC it 'shuffles strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).not_to match(%r{shuffle is "blowzy night-frumps vex'd jack q"}) diff --git a/spec/acceptance/size_spec.rb b/spec/acceptance/size_spec.rb index 6c4e9f47b..64452648e 100755 --- a/spec/acceptance/size_spec.rb +++ b/spec/acceptance/size_spec.rb @@ -3,44 +3,44 @@ describe 'size function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = 'discombobulate' $o = size($a) notice(inline_template('size is <%= @o.inspect %>')) - EOS + DOC it 'single string size' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{size is 14}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = '' $o = size($a) notice(inline_template('size is <%= @o.inspect %>')) - EOS + DOC it 'with empty string' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{size is 0}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = undef $o = size($a) notice(inline_template('size is <%= @o.inspect %>')) - EOS + DOC it 'with undef' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{size is 0}) end end - pp4 = <<-EOS + pp4 = <<-DOC $a = ['discombobulate', 'moo'] $o = size($a) notice(inline_template('size is <%= @o.inspect %>')) - EOS + DOC it 'strings in array' do apply_manifest(pp4, :catch_failures => true) do |r| expect(r.stdout).to match(%r{size is 2}) diff --git a/spec/acceptance/sort_spec.rb b/spec/acceptance/sort_spec.rb index 6feedd7aa..12ed9a4cd 100755 --- a/spec/acceptance/sort_spec.rb +++ b/spec/acceptance/sort_spec.rb @@ -3,23 +3,23 @@ describe 'sort function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ["the","public","art","galleries"] # Anagram: Large picture halls, I bet $o = sort($a) notice(inline_template('sort is <%= @o.inspect %>')) - EOS + DOC it 'sorts arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{sort is \["art", "galleries", "public", "the"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "blowzy night-frumps vex'd jack q" $o = sort($a) notice(inline_template('sort is <%= @o.inspect %>')) - EOS + DOC it 'sorts strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{sort is " '-abcdefghijklmnopqrstuvwxyz"}) diff --git a/spec/acceptance/squeeze_spec.rb b/spec/acceptance/squeeze_spec.rb index 9cd2b2605..553ad8084 100755 --- a/spec/acceptance/squeeze_spec.rb +++ b/spec/acceptance/squeeze_spec.rb @@ -3,12 +3,12 @@ describe 'squeeze function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC # Real words! $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"] $o = squeeze($a) notice(inline_template('squeeze is <%= @o.inspect %>')) - EOS + DOC it 'squeezes arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]}) @@ -16,22 +16,22 @@ end it 'squeezez arrays with an argument' - pp2 = <<-EOS + pp2 = <<-DOC $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" $o = squeeze($a) notice(inline_template('squeeze is <%= @o.inspect %>')) - EOS + DOC it 'squeezes strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{squeeze is "wales laparohysterosalpingophorectomy br godeship"}) end end - pp3 = <<-EOS + pp3 = <<-DOC $a = "countessship duchessship governessship hostessship" $o = squeeze($a, 's') notice(inline_template('squeeze is <%= @o.inspect %>')) - EOS + DOC it 'squeezes strings with an argument' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{squeeze is "counteship ducheship governeship hosteship"}) diff --git a/spec/acceptance/str2bool_spec.rb b/spec/acceptance/str2bool_spec.rb index c36e32bd9..7e5a6dde6 100755 --- a/spec/acceptance/str2bool_spec.rb +++ b/spec/acceptance/str2bool_spec.rb @@ -3,10 +3,10 @@ describe 'str2bool function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = str2bool('y') notice(inline_template('str2bool is <%= @o.inspect %>')) - EOS + DOC it 'works with "y"' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{str2bool is true}) diff --git a/spec/acceptance/str2saltedsha512_spec.rb b/spec/acceptance/str2saltedsha512_spec.rb index 832befa59..e3e8116e7 100755 --- a/spec/acceptance/str2saltedsha512_spec.rb +++ b/spec/acceptance/str2saltedsha512_spec.rb @@ -3,10 +3,10 @@ describe 'str2saltedsha512 function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = str2saltedsha512('password') notice(inline_template('str2saltedsha512 is <%= @o.inspect %>')) - EOS + DOC it 'works with "y"' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{str2saltedsha512 is "[a-f0-9]{136}"}) diff --git a/spec/acceptance/strftime_spec.rb b/spec/acceptance/strftime_spec.rb index 49a89098b..34c5cbc9d 100755 --- a/spec/acceptance/strftime_spec.rb +++ b/spec/acceptance/strftime_spec.rb @@ -3,10 +3,10 @@ describe 'strftime function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = strftime('%C') notice(inline_template('strftime is <%= @o.inspect %>')) - EOS + DOC it 'gives the Century' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{strftime is "20"}) diff --git a/spec/acceptance/strip_spec.rb b/spec/acceptance/strip_spec.rb index fb7f76606..fa5e7c564 100755 --- a/spec/acceptance/strip_spec.rb +++ b/spec/acceptance/strip_spec.rb @@ -3,23 +3,23 @@ describe 'strip function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = [" the "," public "," art","galleries "] # Anagram: Large picture halls, I bet $o = strip($a) notice(inline_template('strip is <%= @o.inspect %>')) - EOS + DOC it 'strips arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{strip is \["the", "public", "art", "galleries"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = " blowzy night-frumps vex'd jack q " $o = strip($a) notice(inline_template('strip is <%= @o.inspect %>')) - EOS + DOC it 'strips strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{strip is "blowzy night-frumps vex'd jack q"}) diff --git a/spec/acceptance/suffix_spec.rb b/spec/acceptance/suffix_spec.rb index 93ac25710..4b90fdb74 100755 --- a/spec/acceptance/suffix_spec.rb +++ b/spec/acceptance/suffix_spec.rb @@ -3,30 +3,30 @@ describe 'suffix function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $o = suffix(['a','b','c'],'p') notice(inline_template('suffix is <%= @o.inspect %>')) - EOS + DOC it 'suffixes array of values' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{suffix is \["ap", "bp", "cp"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $o = suffix([],'p') notice(inline_template('suffix is <%= @o.inspect %>')) - EOS + DOC it 'suffixs with empty array' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{suffix is \[\]}) end end - pp3 = <<-EOS + pp3 = <<-DOC $o = suffix(['a','b','c'], undef) notice(inline_template('suffix is <%= @o.inspect %>')) - EOS + DOC it 'suffixs array of values with undef' do apply_manifest(pp3, :catch_failures => true) do |r| expect(r.stdout).to match(%r{suffix is \["a", "b", "c"\]}) diff --git a/spec/acceptance/swapcase_spec.rb b/spec/acceptance/swapcase_spec.rb index 782a3d543..c2794c057 100755 --- a/spec/acceptance/swapcase_spec.rb +++ b/spec/acceptance/swapcase_spec.rb @@ -3,10 +3,10 @@ describe 'swapcase function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = swapcase('aBcD') notice(inline_template('swapcase is <%= @o.inspect %>')) - EOS + DOC it 'works with strings' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{swapcase is "AbCd"}) diff --git a/spec/acceptance/time_spec.rb b/spec/acceptance/time_spec.rb index 784fde294..2b4ba452f 100755 --- a/spec/acceptance/time_spec.rb +++ b/spec/acceptance/time_spec.rb @@ -3,10 +3,10 @@ describe 'time function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $o = time() notice(inline_template('time is <%= @o.inspect %>')) - EOS + DOC it 'gives the time' do apply_manifest(pp1, :catch_failures => true) do |r| m = r.stdout.match(%r{time is (\d+)\D}) @@ -15,10 +15,10 @@ end end - pp2 = <<-EOS + pp2 = <<-DOC $o = time('UTC') notice(inline_template('time is <%= @o.inspect %>')) - EOS + DOC it 'takes a timezone argument' do apply_manifest(pp2, :catch_failures => true) do |r| m = r.stdout.match(%r{time is (\d+)\D}) diff --git a/spec/acceptance/to_bytes_spec.rb b/spec/acceptance/to_bytes_spec.rb index 20bcff394..21fbd9515 100755 --- a/spec/acceptance/to_bytes_spec.rb +++ b/spec/acceptance/to_bytes_spec.rb @@ -3,10 +3,10 @@ describe 'to_bytes function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $o = to_bytes('4 kB') notice(inline_template('to_bytes is <%= @o.inspect %>')) - EOS + DOC it 'converts kB to B' do apply_manifest(pp, :catch_failures => true) do |r| m = r.stdout.match(%r{to_bytes is (\d+)\D}) diff --git a/spec/acceptance/try_get_value_spec.rb b/spec/acceptance/try_get_value_spec.rb index dd512e450..1a892f8cd 100755 --- a/spec/acceptance/try_get_value_spec.rb +++ b/spec/acceptance/try_get_value_spec.rb @@ -3,14 +3,14 @@ describe 'try_get_value function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $data = { 'a' => { 'b' => 'passing'} } $tests = try_get_value($data, 'a/b') notice(inline_template('tests are <%= @tests.inspect %>')) - EOS + DOC it 'gets a value' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{tests are "passing"}) @@ -19,23 +19,23 @@ end describe 'failure' do - pp2 = <<-EOS + pp2 = <<-DOC $data = { 'a' => { 'b' => 'passing'} } $tests = try_get_value($data, 'c/d', 'using the default value') notice(inline_template('tests are <%= @tests.inspect %>')) - EOS + DOC it 'uses a default value' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{using the default value}) end end - pp = <<-EOS + pp = <<-DOC $o = try_get_value() - EOS + DOC it 'raises error on incorrect number of arguments' do apply_manifest(pp, :expect_failures => true) do |r| expect(r.stderr).to match(%r{wrong number of arguments}i) diff --git a/spec/acceptance/type_spec.rb b/spec/acceptance/type_spec.rb index 777bb23f7..7fb830054 100755 --- a/spec/acceptance/type_spec.rb +++ b/spec/acceptance/type_spec.rb @@ -3,23 +3,23 @@ describe 'type function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ["the","public","art","galleries"] # Anagram: Large picture halls, I bet $o = type($a) notice(inline_template('type is <%= @o.to_s %>')) - EOS + DOC it 'types arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{type is Tuple\[String.*, String.*, String.*, String.*\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "blowzy night-frumps vex'd jack q" $o = type($a) notice(inline_template('type is <%= @o.to_s %>')) - EOS + DOC it 'types strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{type is String}) diff --git a/spec/acceptance/union_spec.rb b/spec/acceptance/union_spec.rb index 0965ab0b9..414728e7a 100755 --- a/spec/acceptance/union_spec.rb +++ b/spec/acceptance/union_spec.rb @@ -3,14 +3,14 @@ describe 'union function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ["the","public"] $b = ["art"] $c = ["galleries"] # Anagram: Large picture halls, I bet $o = union($a,$b,$c) notice(inline_template('union is <%= @o.inspect %>')) - EOS + DOC it 'unions arrays' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{union is \["the", "public", "art", "galleries"\]}) diff --git a/spec/acceptance/unique_spec.rb b/spec/acceptance/unique_spec.rb index ea8455fad..4c3c26f8a 100755 --- a/spec/acceptance/unique_spec.rb +++ b/spec/acceptance/unique_spec.rb @@ -3,22 +3,22 @@ describe 'unique function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ["wallless", "wallless", "brrr", "goddessship"] $o = unique($a) notice(inline_template('unique is <%= @o.inspect %>')) - EOS + DOC it 'uniques arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{unique is \["wallless", "brrr", "goddessship"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" $o = unique($a) notice(inline_template('unique is <%= @o.inspect %>')) - EOS + DOC it 'uniques strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{unique is "wales prohytingcmbd"}) diff --git a/spec/acceptance/upcase_spec.rb b/spec/acceptance/upcase_spec.rb index f153dcb04..9236adc00 100755 --- a/spec/acceptance/upcase_spec.rb +++ b/spec/acceptance/upcase_spec.rb @@ -3,22 +3,22 @@ describe 'upcase function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"] $o = upcase($a) notice(inline_template('upcase is <%= @o.inspect %>')) - EOS + DOC it 'upcases arrays' do apply_manifest(pp1, :catch_failures => true) do |r| expect(r.stdout).to match(%r{upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]}) end end - pp2 = <<-EOS + pp2 = <<-DOC $a = "wallless laparohysterosalpingooophorectomy brrr goddessship" $o = upcase($a) notice(inline_template('upcase is <%= @o.inspect %>')) - EOS + DOC it 'upcases strings' do apply_manifest(pp2, :catch_failures => true) do |r| expect(r.stdout).to match(%r{upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"}) diff --git a/spec/acceptance/uriescape_spec.rb b/spec/acceptance/uriescape_spec.rb index d3b39fadc..5d7890bf9 100755 --- a/spec/acceptance/uriescape_spec.rb +++ b/spec/acceptance/uriescape_spec.rb @@ -3,11 +3,11 @@ describe 'uriescape function' do describe 'success' do - pp = <<-EOS + pp = <<-DOC $a = ":/?#[]@!$&'()*+,;= \\\"{}" $o = uriescape($a) notice(inline_template('uriescape is <%= @o.inspect %>')) - EOS + DOC it 'uriescape strings' do apply_manifest(pp, :catch_failures => true) do |r| expect(r.stdout).to match(%r{uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"}) diff --git a/spec/acceptance/validate_absolute_path_spec.rb b/spec/acceptance/validate_absolute_path_spec.rb index fec28174b..c1e931335 100755 --- a/spec/acceptance/validate_absolute_path_spec.rb +++ b/spec/acceptance/validate_absolute_path_spec.rb @@ -14,10 +14,10 @@ /var/lib/puppet /var/opt/../lib/puppet ].each do |path| - pp = <<-EOS + pp = <<-DOC $one = '#{path}' validate_absolute_path($one) - EOS + DOC it "validates a single argument #{path}" do apply_manifest(pp, :catch_failures => true) end diff --git a/spec/acceptance/validate_array_spec.rb b/spec/acceptance/validate_array_spec.rb index 8116fd2ce..9611626e6 100755 --- a/spec/acceptance/validate_array_spec.rb +++ b/spec/acceptance/validate_array_spec.rb @@ -3,19 +3,19 @@ describe 'validate_array function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = ['a', 'b'] validate_array($one) - EOS + DOC it 'validates a single argument' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = ['a', 'b'] $two = [['c'], 'd'] validate_array($one,$two) - EOS + DOC it 'validates an multiple arguments' do apply_manifest(pp2, :catch_failures => true) end diff --git a/spec/acceptance/validate_augeas_spec.rb b/spec/acceptance/validate_augeas_spec.rb index 098ff280e..1cf412d08 100755 --- a/spec/acceptance/validate_augeas_spec.rb +++ b/spec/acceptance/validate_augeas_spec.rb @@ -6,53 +6,53 @@ it 'installs augeas for tests' end describe 'success' do - context 'valid inputs with no 3rd argument' do + context 'with valid inputs with no 3rd argument' do { 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns', 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns', }.each do |line, lens| - pp1 = <<-EOS + pp1 = <<-DOC $line = "#{line}" $lens = "#{lens}" validate_augeas($line, $lens) - EOS + DOC it "validates a single argument for #{lens}" do apply_manifest(pp1, :catch_failures => true) end end end - context 'valid inputs with 3rd and 4th arguments' do + context 'with valid inputs with 3rd and 4th arguments' do line = 'root:x:0:0:root:/root:/bin/barsh\n' lens = 'Passwd.lns' restriction = '$file/*[shell="/bin/barsh"]' - pp2 = <<-EOS + pp2 = <<-DOC $line = "#{line}" $lens = "#{lens}" $restriction = ['#{restriction}'] validate_augeas($line, $lens, $restriction, "my custom failure message") - EOS + DOC it 'validates a restricted value' do expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{my custom failure message}) end end - context 'invalid inputs' do + context 'with invalid inputs' do { 'root:x:0:0:root' => 'Passwd.lns', '127.0.1.1' => 'Hosts.lns', }.each do |line, lens| - pp3 = <<-EOS + pp3 = <<-DOC $line = "#{line}" $lens = "#{lens}" validate_augeas($line, $lens) - EOS + DOC it "validates a single argument for #{lens}" do apply_manifest(pp3, :expect_failures => true) end end end - context 'garbage inputs' do + context 'with garbage inputs' do it 'raises an error on invalid inputs' end end diff --git a/spec/acceptance/validate_bool_spec.rb b/spec/acceptance/validate_bool_spec.rb index 0d1ab2f69..9c6202bd3 100755 --- a/spec/acceptance/validate_bool_spec.rb +++ b/spec/acceptance/validate_bool_spec.rb @@ -3,19 +3,19 @@ describe 'validate_bool function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = true validate_bool($one) - EOS + DOC it 'validates a single argument' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = true $two = false validate_bool($one,$two) - EOS + DOC it 'validates an multiple arguments' do apply_manifest(pp2, :catch_failures => true) end diff --git a/spec/acceptance/validate_cmd_spec.rb b/spec/acceptance/validate_cmd_spec.rb index d6abceb86..b251a5967 100755 --- a/spec/acceptance/validate_cmd_spec.rb +++ b/spec/acceptance/validate_cmd_spec.rb @@ -3,7 +3,7 @@ describe 'validate_cmd function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = 'foo' if $::osfamily == 'windows' { $two = 'echo' #shell built-in @@ -11,12 +11,12 @@ $two = '/bin/echo' } validate_cmd($one,$two) - EOS + DOC it 'validates a true command' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = 'foo' if $::osfamily == 'windows' { $two = 'C:/aoeu' @@ -24,12 +24,12 @@ $two = '/bin/aoeu' } validate_cmd($one,$two) - EOS + DOC it 'validates a fail command' do apply_manifest(pp2, :expect_failures => true) end - pp3 = <<-EOS + pp3 = <<-DOC $one = 'foo' if $::osfamily == 'windows' { $two = 'C:/aoeu' @@ -37,7 +37,7 @@ $two = '/bin/aoeu' } validate_cmd($one,$two,"aoeu is dvorak") - EOS + DOC it 'validates a fail command with a custom error message' do apply_manifest(pp3, :expect_failures => true) do |output| expect(output.stderr).to match(%r{aoeu is dvorak}) diff --git a/spec/acceptance/validate_hash_spec.rb b/spec/acceptance/validate_hash_spec.rb index 075bed139..09041045f 100755 --- a/spec/acceptance/validate_hash_spec.rb +++ b/spec/acceptance/validate_hash_spec.rb @@ -3,19 +3,19 @@ describe 'validate_hash function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = { 'a' => 1 } validate_hash($one) - EOS + DOC it 'validates a single argument' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = { 'a' => 1 } $two = { 'b' => 2 } validate_hash($one,$two) - EOS + DOC it 'validates an multiple arguments' do apply_manifest(pp2, :catch_failures => true) end diff --git a/spec/acceptance/validate_ipv4_address_spec.rb b/spec/acceptance/validate_ipv4_address_spec.rb index 7c1c9d136..423c152e3 100755 --- a/spec/acceptance/validate_ipv4_address_spec.rb +++ b/spec/acceptance/validate_ipv4_address_spec.rb @@ -3,19 +3,19 @@ describe 'validate_ipv4_address function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = '1.2.3.4' validate_ipv4_address($one) - EOS + DOC it 'validates a single argument' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = '1.2.3.4' $two = '5.6.7.8' validate_ipv4_address($one,$two) - EOS + DOC it 'validates an multiple arguments' do apply_manifest(pp2, :catch_failures => true) end diff --git a/spec/acceptance/validate_ipv6_address_spec.rb b/spec/acceptance/validate_ipv6_address_spec.rb index ae546ad6a..352fa1573 100755 --- a/spec/acceptance/validate_ipv6_address_spec.rb +++ b/spec/acceptance/validate_ipv6_address_spec.rb @@ -3,19 +3,19 @@ describe 'validate_ipv6_address function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = '3ffe:0505:0002::' validate_ipv6_address($one) - EOS + DOC it 'validates a single argument' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = '3ffe:0505:0002::' $two = '3ffe:0505:0001::' validate_ipv6_address($one,$two) - EOS + DOC it 'validates an multiple arguments' do apply_manifest(pp2, :catch_failures => true) end diff --git a/spec/acceptance/validate_re_spec.rb b/spec/acceptance/validate_re_spec.rb index 0679ef03c..e7cd03d49 100755 --- a/spec/acceptance/validate_re_spec.rb +++ b/spec/acceptance/validate_re_spec.rb @@ -3,38 +3,38 @@ describe 'validate_re function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = 'one' $two = '^one$' validate_re($one,$two) - EOS + DOC it 'validates a string' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = 'one' $two = ['^one$', '^two'] validate_re($one,$two) - EOS + DOC it 'validates an array' do apply_manifest(pp2, :catch_failures => true) end - pp3 = <<-EOS + pp3 = <<-DOC $one = 'one' $two = ['^two$', '^three'] validate_re($one,$two) - EOS + DOC it 'validates a failed array' do apply_manifest(pp3, :expect_failures => true) end - pp4 = <<-EOS + pp4 = <<-DOC $one = '3.4.3' $two = '^2.7' validate_re($one,$two,"The $puppetversion fact does not match 2.7") - EOS + DOC it 'validates a failed array with a custom error message' do expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{does not match}) end diff --git a/spec/acceptance/validate_slength_spec.rb b/spec/acceptance/validate_slength_spec.rb index 0a1908e86..b3163a993 100755 --- a/spec/acceptance/validate_slength_spec.rb +++ b/spec/acceptance/validate_slength_spec.rb @@ -3,58 +3,58 @@ describe 'validate_slength function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = 'discombobulate' $two = 17 validate_slength($one,$two) - EOS + DOC it 'validates a single string max' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = ['discombobulate', 'moo'] $two = 17 validate_slength($one,$two) - EOS + DOC it 'validates multiple string maxes' do apply_manifest(pp2, :catch_failures => true) end - pp3 = <<-EOS + pp3 = <<-DOC $one = ['discombobulate', 'moo'] $two = 17 $three = 3 validate_slength($one,$two,$three) - EOS + DOC it 'validates min/max of strings in array' do apply_manifest(pp3, :catch_failures => true) end - pp4 = <<-EOS + pp4 = <<-DOC $one = 'discombobulate' $two = 1 validate_slength($one,$two) - EOS + DOC it 'validates a single string max of incorrect length' do apply_manifest(pp4, :expect_failures => true) end - pp5 = <<-EOS + pp5 = <<-DOC $one = ['discombobulate', 'moo'] $two = 3 validate_slength($one,$two) - EOS + DOC it 'validates multiple string maxes of incorrect length' do apply_manifest(pp5, :expect_failures => true) end - pp6 = <<-EOS + pp6 = <<-DOC $one = ['discombobulate', 'moo'] $two = 17 $three = 10 validate_slength($one,$two,$three) - EOS + DOC it 'validates multiple strings min/maxes of incorrect length' do apply_manifest(pp6, :expect_failures => true) end diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb index 3323925d7..d286b5c58 100755 --- a/spec/acceptance/validate_string_spec.rb +++ b/spec/acceptance/validate_string_spec.rb @@ -3,26 +3,26 @@ describe 'validate_string function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = 'string' validate_string($one) - EOS + DOC it 'validates a single argument' do apply_manifest(pp1, :catch_failures => true) end - pp2 = <<-EOS + pp2 = <<-DOC $one = 'string' $two = 'also string' validate_string($one,$two) - EOS + DOC it 'validates an multiple arguments' do apply_manifest(pp2, :catch_failures => true) end - pp3 = <<-EOS + pp3 = <<-DOC validate_string(undef) - EOS + DOC it 'validates undef' do apply_manifest(pp3, :catch_failures => true) end diff --git a/spec/acceptance/values_at_spec.rb b/spec/acceptance/values_at_spec.rb index 83d84d1e7..64bb9a1d0 100755 --- a/spec/acceptance/values_at_spec.rb +++ b/spec/acceptance/values_at_spec.rb @@ -3,64 +3,64 @@ describe 'values_at function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = ['a','b','c','d','e'] $two = 1 $output = values_at($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'returns a specific value' do expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\["b"\]}) end - pp2 = <<-EOS + pp2 = <<-DOC $one = ['a','b','c','d','e'] $two = -1 $output = values_at($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'returns a specific negative index value' do pending("negative numbers don't work") expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\["e"\]}) end - pp3 = <<-EOS + pp3 = <<-DOC $one = ['a','b','c','d','e'] $two = "1-3" $output = values_at($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'returns a range of values' do expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\["b", "c", "d"\]}) end - pp4 = <<-EOS + pp4 = <<-DOC $one = ['a','b','c','d','e'] $two = ["1-3",0] $output = values_at($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'returns a negative specific value and range of values' do expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\["b", "c", "d", "a"\]}) end end describe 'failure' do - pp5 = <<-EOS + pp5 = <<-DOC $one = ['a','b','c','d','e'] $output = values_at($one) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'handles improper number of arguments' do expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments}) end - pp6 = <<-EOS + pp6 = <<-DOC $one = ['a','b','c','d','e'] $two = [] $output = values_at($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'handles non-indicies arguments' do expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{at least one positive index}) end diff --git a/spec/acceptance/values_spec.rb b/spec/acceptance/values_spec.rb index fedd735dc..7ebed500d 100755 --- a/spec/acceptance/values_spec.rb +++ b/spec/acceptance/values_spec.rb @@ -3,7 +3,7 @@ describe 'values function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $arg = { 'a' => 1, 'b' => 2, @@ -11,18 +11,18 @@ } $output = values($arg) notice(inline_template('<%= @output.sort.inspect %>')) - EOS + DOC it 'returns an array of values' do expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[1, 2, 3\]}) end end describe 'failure' do - pp2 = <<-EOS + pp2 = <<-DOC $arg = "foo" $output = values($arg) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'handles non-hash arguments' do expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash}) end diff --git a/spec/acceptance/zip_spec.rb b/spec/acceptance/zip_spec.rb index e0f4f3f5a..316d5671b 100755 --- a/spec/acceptance/zip_spec.rb +++ b/spec/acceptance/zip_spec.rb @@ -3,22 +3,22 @@ describe 'zip function' do describe 'success' do - pp1 = <<-EOS + pp1 = <<-DOC $one = [1,2,3,4] $two = [5,6,7,8] $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'zips two arrays of numbers together' do expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]}) end - pp2 = <<-EOS + pp2 = <<-DOC $one = [1,2,"three",4] $two = [true,true,false,false] $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'zips two arrays of numbers & bools together' do expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]}) end @@ -27,44 +27,44 @@ # 1 t y true yes # 0 f n false no # undef undefined - pp3 = <<-EOS + pp3 = <<-DOC $one = [1,2,3,4] $two = [5,6,7,8] $output = zip($one,$two,true) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'zips two arrays of numbers together and flattens them' do expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\[1, 5, 2, 6, 3, 7, 4, 8\]}) end # XXX Is this expected behavior? - pp4 = <<-EOS + pp4 = <<-DOC $one = [1,2] $two = [5,6,7,8] $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'handles unmatched length' do expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\]\]}) end end describe 'failure' do - pp5 = <<-EOS + pp5 = <<-DOC $one = [1,2] $output = zip($one) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'handles improper number of arguments' do expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments}) end - pp6 = <<-EOS + pp6 = <<-DOC $one = "a string" $two = [5,6,7,8] $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) - EOS + DOC it 'handles improper argument types' do expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{Requires array}) end diff --git a/spec/functions/basename_spec.rb b/spec/functions/basename_spec.rb index d751d92ec..6957133e4 100755 --- a/spec/functions/basename_spec.rb +++ b/spec/functions/basename_spec.rb @@ -12,7 +12,7 @@ it { is_expected.to run.with_params('relative_path/to/a/file.ext', '.ext').and_return('file') } it { is_expected.to run.with_params('scheme:///path/to/a/file.ext').and_return('file.ext') } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('竹.ext') } it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ', '.ㄘ').and_return('竹') } end diff --git a/spec/functions/chomp_spec.rb b/spec/functions/chomp_spec.rb index c511ab79e..aabf5961d 100755 --- a/spec/functions/chomp_spec.rb +++ b/spec/functions/chomp_spec.rb @@ -18,7 +18,7 @@ it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(%w[one two three]) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } end diff --git a/spec/functions/chop_spec.rb b/spec/functions/chop_spec.rb index 4150e2529..7b7c5970b 100755 --- a/spec/functions/chop_spec.rb +++ b/spec/functions/chop_spec.rb @@ -18,7 +18,7 @@ it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") } it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(%w[one tw three]) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") } end diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index a43cfb6ee..c9f2ae50d 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -12,7 +12,7 @@ it { is_expected.to run.with_params(%w[1 2], %w[3 4], %w[5 6]).and_return(%w[1 2 3 4 5 6]) } it { is_expected.to run.with_params(%w[1 2], '3', '4', %w[5 6]).and_return(%w[1 2 3 4 5 6]) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params([{ 'a' => 'b' }], 'c' => 'd', 'e' => 'f').and_return([{ 'a' => 'b' }, { 'c' => 'd', 'e' => 'f' }]) } it { is_expected.to run.with_params(['ấ', 'β', '©'], %w[đ ể 文字列]).and_return(['ấ', 'β', '©', 'đ', 'ể', '文字列']) } end diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index 74d20a75c..d09bde0ee 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -52,7 +52,7 @@ end end - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params({ 'ĸέỹ1' => 'ϋǻļủë1' }, 'この文字列' => '万').and_return('ĸέỹ1' => 'ϋǻļủë1', 'この文字列' => '万') } end end diff --git a/spec/functions/defined_with_params_spec.rb b/spec/functions/defined_with_params_spec.rb index 5715f6f1b..d404ba9a6 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -13,7 +13,7 @@ it { is_expected.to run.with_params('User[bob]', {}).and_return(false) } it { is_expected.to run.with_params('User[dan]', 'foo' => 'bar').and_return(false) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('User[ĵĭмოү]', {}).and_return(false) } it { is_expected.to run.with_params('User[ポーラ]', {}).and_return(false) } end @@ -45,11 +45,11 @@ 'user { "dan": }' end - context 'reference' do + context 'with reference' do it { is_expected.to run.with_params(Puppet::Resource.new('User[dan]'), {}).and_return(true) } end if Puppet::Util::Package.versioncmp(Puppet.version, '4.6.0') >= 0 - context 'array' do + context 'with array' do it 'fails' do expect { subject.call([['User[dan]'], {}]) diff --git a/spec/functions/dig44_spec.rb b/spec/functions/dig44_spec.rb index 48236b642..c721b0cbf 100644 --- a/spec/functions/dig44_spec.rb +++ b/spec/functions/dig44_spec.rb @@ -36,7 +36,7 @@ } end - context 'single values' do + context 'with single values' do it 'exists' do is_expected.not_to be_nil end @@ -78,7 +78,7 @@ end end - context 'structure values' do + context 'with structured values' do it 'is able to extract a deeply nested hash value' do is_expected.to run.with_params(data, %w[a g], 'default').and_return('2') end @@ -112,7 +112,7 @@ end end - context 'Internationalization (i18N) values' do + context 'with internationalization (i18N) values' do it 'is able to return a unicode character' do is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 0]).and_return('©') end diff --git a/spec/functions/dirname_spec.rb b/spec/functions/dirname_spec.rb index 8c410cc90..da62eeaaf 100755 --- a/spec/functions/dirname_spec.rb +++ b/spec/functions/dirname_spec.rb @@ -11,7 +11,7 @@ it { is_expected.to run.with_params('/path/to/a/file.ext').and_return('/path/to/a') } it { is_expected.to run.with_params('relative_path/to/a/file.ext').and_return('relative_path/to/a') } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('scheme:///√ạĺűē') } it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ').and_return('ҝẽγ:/√ạĺűē') } end diff --git a/spec/functions/dos2unix_spec.rb b/spec/functions/dos2unix_spec.rb index cba0bc61b..8677d8c27 100644 --- a/spec/functions/dos2unix_spec.rb +++ b/spec/functions/dos2unix_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'dos2unix' do - context 'Checking parameter validity' do + context 'when checking parameter validity' do it { is_expected.not_to eq(nil) } it do is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) @@ -20,7 +20,7 @@ end end - context 'Converting from dos to unix format' do + context 'when converting from dos to unix format' do sample_text = "Hello\r\nWorld\r\n" desired_output = "Hello\nWorld\n" @@ -29,7 +29,7 @@ end end - context 'Internationalization (i18N) values' do + context 'with internationalization (i18N) values' do sample_text_utf8 = "Ħ℮ļłǿ\r\nשׁөŕłđ\r\n" desired_output_utf8 = "Ħ℮ļłǿ\nשׁөŕłđ\n" diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 0428008b0..6bdb015c6 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -14,7 +14,7 @@ it { is_expected.to run.with_params('packagename') } it { is_expected.to run.with_params(%w[packagename1 packagename2]) } - context 'given a catalog with "package { puppet: ensure => absent }"' do + context 'when given a catalog with "package { puppet: ensure => absent }"' do let(:pre_condition) { 'package { puppet: ensure => absent }' } describe 'after running ensure_package("facter")' do @@ -34,7 +34,7 @@ end end - context 'given an empty packages array' do + context 'when given an empty packages array' do let(:pre_condition) { 'notify { "hi": } -> Package <| |>; $somearray = ["vim",""]; ensure_packages($somearray)' } describe 'after running ensure_package(["vim", ""])' do @@ -42,7 +42,7 @@ end end - context 'given hash of packages' do + context 'when given hash of packages' do before(:each) do subject.call([{ 'foo' => { 'provider' => 'rpm' }, 'bar' => { 'provider' => 'gem' } }, { 'ensure' => 'present' }]) subject.call([{ 'パッケージ' => { 'ensure' => 'absent' } }]) @@ -53,13 +53,13 @@ it { expect(-> { catalogue }).to contain_package('foo').with('provider' => 'rpm', 'ensure' => 'present') } it { expect(-> { catalogue }).to contain_package('bar').with('provider' => 'gem', 'ensure' => 'present') } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { expect(-> { catalogue }).to contain_package('パッケージ').with('ensure' => 'absent') } it { expect(-> { catalogue }).to contain_package('ρǻ¢κầģẻ').with('ensure' => 'absent') } end end - context 'given a catalog with "package { puppet: ensure => present }"' do + context 'when given a catalog with "package { puppet: ensure => present }"' do let(:pre_condition) { 'package { puppet: ensure => present }' } describe 'after running ensure_package("puppet", { "ensure" => "installed" })' do diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index aa2e1a2d9..3ef3b70d4 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -15,7 +15,7 @@ is_expected.to run.with_params(1, 2, 3).and_raise_error(Puppet::ParseError) } - context 'given an empty catalog' do + context 'when given an empty catalog' do describe 'after running ensure_resource("user", "username1", {})' do before(:each) { subject.call(['User', 'username1', {}]) } @@ -47,7 +47,7 @@ end end - context 'given a catalog with UTF8 chars' do + context 'when given a catalog with UTF8 chars' do describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do before(:each) { subject.call(['User', 'Şắოрŀễ Ţëם', {}]) } @@ -72,7 +72,7 @@ end end - context 'given a catalog with "user { username1: ensure => present }"' do + context 'when given a catalog with "user { username1: ensure => present }"' do let(:pre_condition) { 'user { username1: ensure => present }' } describe 'after running ensure_resource("user", "username1", {})' do @@ -124,7 +124,7 @@ end end - context 'given a catalog with "test::deftype { foo: }"' do + context 'when given a catalog with "test::deftype { foo: }"' do let(:pre_condition) { 'test::deftype { "foo": }' } describe 'after running ensure_resource("test::deftype", "foo", {})' do diff --git a/spec/functions/fqdn_uuid_spec.rb b/spec/functions/fqdn_uuid_spec.rb index 7e59bb660..a6da6f26a 100644 --- a/spec/functions/fqdn_uuid_spec.rb +++ b/spec/functions/fqdn_uuid_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe 'fqdn_uuid' do - context 'Invalid parameters' do + context 'with invalid parameters' do it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{No arguments given$}) } end - context 'given string' do + context 'with given string' do it { is_expected.to run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') } it { is_expected.to run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') } end diff --git a/spec/functions/get_module_path_spec.rb b/spec/functions/get_module_path_spec.rb index cc922dd7b..9f448b395 100755 --- a/spec/functions/get_module_path_spec.rb +++ b/spec/functions/get_module_path_spec.rb @@ -20,7 +20,7 @@ def initialize(path) before(:each) { Puppet[:modulepath] = modulepath } - context 'in the default environment' do + context 'when in the default environment' do before(:each) { Puppet::Module.expects(:find).with('foo', 'rp_env').returns(path_of_module_foo) } it { is_expected.to run.with_params('foo').and_return(path_of_module_foo.path) } @@ -32,7 +32,7 @@ def initialize(path) end end - context 'in a non-default default environment' do + context 'when in a non-default default environment' do let(:environment) { 'test' } before(:each) { Puppet::Module.expects(:find).with('foo', 'test').returns(path_of_module_foo) } diff --git a/spec/functions/getvar_spec.rb b/spec/functions/getvar_spec.rb index 2cb3a13f8..cb865c787 100755 --- a/spec/functions/getvar_spec.rb +++ b/spec/functions/getvar_spec.rb @@ -7,12 +7,12 @@ it { is_expected.to run.with_params('$::foo').and_return(nil) } - context 'given variables in namespaces' do + context 'with given variables in namespaces' do let(:pre_condition) do - <<-'ENDofPUPPETcode' + <<-PUPPETCODE class site::data { $foo = 'baz' } include site::data - ENDofPUPPETcode + PUPPETCODE end it { is_expected.to run.with_params('site::data::foo').and_return('baz') } @@ -20,14 +20,14 @@ class site::data { $foo = 'baz' } it { is_expected.to run.with_params('::site::data::bar').and_return(nil) } end - context 'given variables in namespaces' do + context 'with given variables in namespaces' do let(:pre_condition) do - <<-'ENDofPUPPETcode' + <<-PUPPETCODE class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' } class site::new { $item = '万Ü€‰' } include site::info include site::new - ENDofPUPPETcode + PUPPETCODE end it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') } diff --git a/spec/functions/has_interface_with_spec.rb b/spec/functions/has_interface_with_spec.rb index a648aa0ac..273ecb250 100755 --- a/spec/functions/has_interface_with_spec.rb +++ b/spec/functions/has_interface_with_spec.rb @@ -7,14 +7,14 @@ # We need to mock out the Facts so we can specify how we expect this function # to behave on different platforms. - context 'On Mac OS X Systems' do + context 'when on Mac OS X Systems' do let(:facts) { { :interfaces => 'lo0,gif0,stf0,en1,p2p0,fw0,en0,vmnet1,vmnet8,utun0' } } it { is_expected.to run.with_params('lo0').and_return(true) } it { is_expected.to run.with_params('lo').and_return(false) } end - context 'On Linux Systems' do + context 'when on Linux Systems' do let(:facts) do { :interfaces => 'eth0,lo', diff --git a/spec/functions/has_ip_address_spec.rb b/spec/functions/has_ip_address_spec.rb index 935214373..33934f35b 100755 --- a/spec/functions/has_ip_address_spec.rb +++ b/spec/functions/has_ip_address_spec.rb @@ -5,7 +5,7 @@ it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - context 'On Linux Systems' do + context 'when on Linux Systems' do let(:facts) do { :interfaces => 'eth0,lo', diff --git a/spec/functions/has_ip_network_spec.rb b/spec/functions/has_ip_network_spec.rb index a10513eea..cc6ff0b02 100755 --- a/spec/functions/has_ip_network_spec.rb +++ b/spec/functions/has_ip_network_spec.rb @@ -5,7 +5,7 @@ it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - context 'On Linux Systems' do + context 'when on Linux Systems' do let(:facts) do { :interfaces => 'eth0,lo', diff --git a/spec/functions/has_key_spec.rb b/spec/functions/has_key_spec.rb index 2416b8134..6abebba26 100755 --- a/spec/functions/has_key_spec.rb +++ b/spec/functions/has_key_spec.rb @@ -13,7 +13,7 @@ it { is_expected.to run.with_params({}, 'key').and_return(false) } it { is_expected.to run.with_params({ 'key' => 'value' }, 'not a key').and_return(false) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params({ 'κéỳ ' => '٧ậļųể' }, 'κéỳ ').and_return(true) } it { is_expected.to run.with_params({ 'キー' => '٧ậļųể' }, 'キー').and_return(true) } end diff --git a/spec/functions/is_array_spec.rb b/spec/functions/is_array_spec.rb index bc8fc30bd..c6c016a89 100755 --- a/spec/functions/is_array_spec.rb +++ b/spec/functions/is_array_spec.rb @@ -16,7 +16,7 @@ it { is_expected.to run.with_params('one').and_return(false) } it { is_expected.to run.with_params(1).and_return(false) } it { is_expected.to run.with_params({}).and_return(false) } - context 'Checking for deprecation warning' do + context 'with deprecation warning' do after(:each) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/is_bool_spec.rb b/spec/functions/is_bool_spec.rb index 85d7cad73..182ef7048 100755 --- a/spec/functions/is_bool_spec.rb +++ b/spec/functions/is_bool_spec.rb @@ -12,7 +12,7 @@ it { is_expected.to run.with_params([true]).and_return(false) } it { is_expected.to run.with_params('true').and_return(false) } it { is_expected.to run.with_params('false').and_return(false) } - context 'Checking for deprecation warning' do + context 'with deprecation warning' do after(:each) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/is_float_spec.rb b/spec/functions/is_float_spec.rb index e5c5d8c85..6f59c3ea4 100755 --- a/spec/functions/is_float_spec.rb +++ b/spec/functions/is_float_spec.rb @@ -21,7 +21,7 @@ it { is_expected.to run.with_params(1).and_return(false) } end - context 'Checking for deprecation warning' do + context 'with deprecation warning' do after(:each) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/is_integer_spec.rb b/spec/functions/is_integer_spec.rb index 2001cd16c..00262cea8 100755 --- a/spec/functions/is_integer_spec.rb +++ b/spec/functions/is_integer_spec.rb @@ -27,7 +27,7 @@ it { is_expected.to run.with_params('0001234').and_return(false) } it { is_expected.to run.with_params("foo\nbar").and_return(false) } - context 'Checking for deprecation warning' do + context 'with deprecation warning' do after(:each) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/is_mac_address_spec.rb b/spec/functions/is_mac_address_spec.rb index 17261b664..1f1570250 100755 --- a/spec/functions/is_mac_address_spec.rb +++ b/spec/functions/is_mac_address_spec.rb @@ -10,7 +10,7 @@ it { is_expected.to run.with_params('').and_return(false) } it { is_expected.to run.with_params('one').and_return(false) } - context 'function can handle UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('ƒốưř').and_return(false) } it { is_expected.to run.with_params('三+').and_return(false) } end diff --git a/spec/functions/is_numeric_spec.rb b/spec/functions/is_numeric_spec.rb index 5eab31f56..c936d7393 100755 --- a/spec/functions/is_numeric_spec.rb +++ b/spec/functions/is_numeric_spec.rb @@ -27,7 +27,7 @@ it { is_expected.to run.with_params('0001234').and_return(false) } it { is_expected.to run.with_params(' - 1234').and_return(false) } - context 'Checking for deprecation warning' do + context 'with deprecation warning' do after(:each) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/is_string_spec.rb b/spec/functions/is_string_spec.rb index 99f2d22c1..98b557802 100755 --- a/spec/functions/is_string_spec.rb +++ b/spec/functions/is_string_spec.rb @@ -26,7 +26,7 @@ it { is_expected.to run.with_params('one').and_return(true) } it { is_expected.to run.with_params('0001234').and_return(true) } - context 'Checking for deprecation warning' do + context 'with deprecation warning' do after(:each) do ENV.delete('STDLIB_LOG_DEPRECATIONS') end diff --git a/spec/functions/join_keys_to_values_spec.rb b/spec/functions/join_keys_to_values_spec.rb index fba508b2f..8800499b2 100755 --- a/spec/functions/join_keys_to_values_spec.rb +++ b/spec/functions/join_keys_to_values_spec.rb @@ -12,7 +12,7 @@ it { is_expected.to run.with_params({ 'key' => 'value' }, '').and_return(['keyvalue']) } it { is_expected.to run.with_params({ 'key' => 'value' }, ':').and_return(['key:value']) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, ':').and_return(['ҝẽγ:√ạĺűē']) } it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, '万').and_return(['ҝẽγ万√ạĺűē']) } end diff --git a/spec/functions/pick_spec.rb b/spec/functions/pick_spec.rb index 52ba706cb..d8c6fbff0 100755 --- a/spec/functions/pick_spec.rb +++ b/spec/functions/pick_spec.rb @@ -10,7 +10,7 @@ it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } it { is_expected.to run.with_params(nil, 'two').and_return('two') } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') } it { is_expected.to run.with_params('', 'ŝẳмрłề џţƒ8 ţẽם', 'このテキスト').and_return('ŝẳмрłề џţƒ8 ţẽם') } end diff --git a/spec/functions/private_spec.rb b/spec/functions/private_spec.rb index 1efc04512..32bb2fd1b 100644 --- a/spec/functions/private_spec.rb +++ b/spec/functions/private_spec.rb @@ -5,7 +5,7 @@ scope.expects(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : unable to cut line to required length begin subject.call [] - rescue # rubocop:disable Lint/HandleExceptions + rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass # ignore this end end diff --git a/spec/functions/regexpescape_spec.rb b/spec/functions/regexpescape_spec.rb index 8a40e20bc..d5b1f1549 100644 --- a/spec/functions/regexpescape_spec.rb +++ b/spec/functions/regexpescape_spec.rb @@ -33,7 +33,7 @@ it { is_expected.to run.with_params(['one*', 'two']).and_return(['one\*', 'two']) } it { is_expected.to run.with_params(['one*', 1, true, {}, 'two']).and_return(['one\*', 1, true, {}, 'two']) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params(['ŏʼnε*']).and_return(['ŏʼnε\*']) } it { is_expected.to run.with_params(['インターネット*']).and_return(['インターネット\*']) } end diff --git a/spec/functions/seeded_rand_spec.rb b/spec/functions/seeded_rand_spec.rb index 206726299..9b7078aff 100644 --- a/spec/functions/seeded_rand_spec.rb +++ b/spec/functions/seeded_rand_spec.rb @@ -51,7 +51,7 @@ def seeded_rand(max, seed, args = {}) scope.function_seeded_rand([max, seed]) end - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params(1000, 'ǿňè') } it { is_expected.to run.with_params(1000, '文字列') } end diff --git a/spec/functions/shell_escape_spec.rb b/spec/functions/shell_escape_spec.rb index 14b88c290..ed63bc384 100644 --- a/spec/functions/shell_escape_spec.rb +++ b/spec/functions/shell_escape_spec.rb @@ -22,7 +22,7 @@ } end - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('スペー スを含むテ キスト').and_return('\\ス\\ペ\\ー\\ \\ス\\を\\含\\む\\テ\\ \\ \\キ\\ス\\ト') } it { is_expected.to run.with_params('μťƒ 8 ŧĕχť').and_return('\\μ\\ť\\ƒ\\ 8\\ \\ \\ŧ\\ĕ\\χ\\ť') } end diff --git a/spec/functions/shell_join_spec.rb b/spec/functions/shell_join_spec.rb index 545b0ce20..b1f7ff2c4 100644 --- a/spec/functions/shell_join_spec.rb +++ b/spec/functions/shell_join_spec.rb @@ -18,7 +18,7 @@ .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params(%w[μťƒ 8 ŧĕχť]).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') } it { is_expected.to run.with_params(['スペー', 'スを含むテ', ' キスト']).and_return('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') } end diff --git a/spec/functions/shell_split_spec.rb b/spec/functions/shell_split_spec.rb index 94e387174..beda04322 100644 --- a/spec/functions/shell_split_spec.rb +++ b/spec/functions/shell_split_spec.rb @@ -25,7 +25,7 @@ .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(%w[μťƒ 8 ŧĕχť]) } it { is_expected.to run.with_params('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト').and_return(['スペー', 'スを含むテ', ' キスト']) } end diff --git a/spec/functions/shuffle_spec.rb b/spec/functions/shuffle_spec.rb index 99784977d..eba3afa63 100755 --- a/spec/functions/shuffle_spec.rb +++ b/spec/functions/shuffle_spec.rb @@ -26,7 +26,7 @@ it { is_expected.to run.with_params('abc').and_return('bac') } it { is_expected.to run.with_params('abcd').and_return('dcba') } - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') } it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') } end diff --git a/spec/functions/sprintf_hash_spec.rb b/spec/functions/sprintf_hash_spec.rb index 297c903aa..4bead465c 100644 --- a/spec/functions/sprintf_hash_spec.rb +++ b/spec/functions/sprintf_hash_spec.rb @@ -5,7 +5,7 @@ is_expected.not_to eq(nil) end - context 'validate param count' do + context 'with param count' do it 'fails with no arguments' do is_expected.to run.with_params.and_raise_error(ArgumentError, %r{expects 2 arguments}i) end @@ -17,7 +17,7 @@ end end - context 'validate param type' do + context 'with param type' do it 'fails with wrong format type' do is_expected.to run.with_params(false, {}).and_raise_error(ArgumentError, %r{parameter 'format' expects a String value}i) end diff --git a/spec/functions/squeeze_spec.rb b/spec/functions/squeeze_spec.rb index ced6e4ff1..05bd88499 100755 --- a/spec/functions/squeeze_spec.rb +++ b/spec/functions/squeeze_spec.rb @@ -16,7 +16,7 @@ it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') } end - context 'should run with UTF8 and double byte characters' do + context 'with UTF8 and double byte characters' do 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/try_get_value_spec.rb b/spec/functions/try_get_value_spec.rb index dc3c9864a..630296bb3 100644 --- a/spec/functions/try_get_value_spec.rb +++ b/spec/functions/try_get_value_spec.rb @@ -22,7 +22,7 @@ } end - context 'single values' do + context 'with single values' do it 'exists' do is_expected.not_to eq(nil) end @@ -44,7 +44,7 @@ end end - context 'structure values' do + context 'with structure values' do it 'is able to extracts a single hash value' do is_expected.to run.with_params(data, 'd', 'default').and_return('1') end diff --git a/spec/functions/unix2dos_spec.rb b/spec/functions/unix2dos_spec.rb index 49fb408cf..a6af64f08 100644 --- a/spec/functions/unix2dos_spec.rb +++ b/spec/functions/unix2dos_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'unix2dos' do - context 'Checking parameter validity' do + context 'when checking parameter validity' do it { is_expected.not_to eq(nil) } it do is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments}) @@ -20,7 +20,7 @@ end end - context 'Converting from unix to dos format' do + context 'when converting from unix to dos format' do sample_text = "Hello\nWorld\n" desired_output = "Hello\r\nWorld\r\n" @@ -29,7 +29,7 @@ end end - context 'Converting from dos to dos format' do + context 'when converting from dos to dos format' do sample_text = "Hello\r\nWorld\r\n" desired_output = "Hello\r\nWorld\r\n" diff --git a/spec/functions/validate_absolute_path_spec.rb b/spec/functions/validate_absolute_path_spec.rb index 54f8cb427..5e93bb37f 100755 --- a/spec/functions/validate_absolute_path_spec.rb +++ b/spec/functions/validate_absolute_path_spec.rb @@ -37,7 +37,7 @@ end describe 'invalid path handling' do - context 'garbage inputs' do + context 'with garbage inputs' do [ nil, [nil], @@ -52,7 +52,7 @@ end end - context 'relative paths' do + context 'with relative paths' do %w[ relative1 . diff --git a/spec/functions/validate_x509_rsa_key_pair_spec.rb b/spec/functions/validate_x509_rsa_key_pair_spec.rb index 3a5913d77..6f5b89700 100755 --- a/spec/functions/validate_x509_rsa_key_pair_spec.rb +++ b/spec/functions/validate_x509_rsa_key_pair_spec.rb @@ -3,7 +3,7 @@ describe 'validate_x509_rsa_key_pair' do # rubocop:disable Lint/IndentHeredoc : Heredoc's are meant to be indented in this way let(:valid_cert) do - < #{puppetversion}" do @@ -62,7 +62,7 @@ end end - context 'When PE is not installed' do + context 'when PE is not installed' do before :each do Facter.fact(:puppetversion).stubs(:value).returns('2.7.19') end diff --git a/spec/unit/facter/root_home_spec.rb b/spec/unit/facter/root_home_spec.rb index d9d2c0fdb..8b6ef3011 100755 --- a/spec/unit/facter/root_home_spec.rb +++ b/spec/unit/facter/root_home_spec.rb @@ -3,7 +3,7 @@ require 'facter/root_home' describe 'Root Home Specs' do describe Facter::Util::RootHome do - context 'solaris' do + context 'when solaris' do let(:root_ent) { 'root:x:0:0:Super-User:/:/sbin/sh' } let(:expected_root_home) { '/' } @@ -12,7 +12,7 @@ expect(described_class.returnt_root_home).to eq(expected_root_home) end end - context 'linux' do + context 'when linux' do let(:root_ent) { 'root:x:0:0:root:/root:/bin/bash' } let(:expected_root_home) { '/root' } @@ -21,7 +21,7 @@ expect(described_class.returnt_root_home).to eq(expected_root_home) end end - context 'windows' do + context 'when windows' do before :each do Facter::Util::Resolution.expects(:exec).with('getent passwd root').returns(nil) end @@ -35,7 +35,7 @@ before(:each) { Facter.clear } after(:each) { Facter.clear } - context 'macosx' do + context 'when macosx' do before(:each) do Facter.fact(:kernel).stubs(:value).returns('Darwin') Facter.fact(:osfamily).stubs(:value).returns('Darwin') @@ -50,7 +50,7 @@ end end - context 'aix' do + context 'when aix' do before(:each) do Facter.fact(:kernel).stubs(:value).returns('AIX') Facter.fact(:osfamily).stubs(:value).returns('AIX') diff --git a/spec/unit/facter/service_provider_spec.rb b/spec/unit/facter/service_provider_spec.rb index f59b8d8ab..77da6339e 100644 --- a/spec/unit/facter/service_provider_spec.rb +++ b/spec/unit/facter/service_provider_spec.rb @@ -7,7 +7,7 @@ before(:each) { Facter.clear } after(:each) { Facter.clear } - context 'macosx' do + context 'when macosx' do it 'returns launchd' do provider = Puppet::Type.type(:service).provider(:launchd) Puppet::Type.type(:service).stubs(:defaultprovider).returns provider @@ -16,7 +16,7 @@ end end - context 'systemd' do + context 'when systemd' do it 'returns systemd' do provider = Puppet::Type.type(:service).provider(:systemd) Puppet::Type.type(:service).stubs(:defaultprovider).returns provider @@ -25,7 +25,7 @@ end end - context 'redhat' do + context 'when redhat' do it 'returns redhat' do provider = Puppet::Type.type(:service).provider(:redhat) Puppet::Type.type(:service).stubs(:defaultprovider).returns provider diff --git a/spec/unit/facter/util/puppet_settings_spec.rb b/spec/unit/facter/util/puppet_settings_spec.rb index 55d6e3cf6..82ef13254 100755 --- a/spec/unit/facter/util/puppet_settings_spec.rb +++ b/spec/unit/facter/util/puppet_settings_spec.rb @@ -4,7 +4,7 @@ describe Facter::Util::PuppetSettings do describe '#with_puppet' do - context 'Without Puppet loaded' do + context 'without Puppet loaded' do before(:each) do Module.expects(:const_get).with('Puppet').raises(NameError) end @@ -17,7 +17,7 @@ expect(subject.with_puppet { Puppet[:vardir] }).to be_nil end end - context 'With Puppet loaded' do + context 'with Puppet loaded' do module Puppet; end let(:vardir) { '/var/lib/puppet' } diff --git a/spec/unit/puppet/provider/file_line/ruby_spec.rb b/spec/unit/puppet/provider/file_line/ruby_spec.rb index 2daab34b5..d76bf38e6 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec.rb @@ -33,14 +33,14 @@ end describe 'line parameter' do - context 'line exists' do + context 'when line exists' do let(:content) { 'foo' } it 'detects the line' do expect(provider).to be_exists end end - context 'line does not exist' do + context 'when line does not exist' do let(:content) { 'foo bar' } it 'requests changes' do @@ -77,7 +77,7 @@ end end - context 'does not match line - line exists' do + context 'when does not match line - line exists' do let(:content) { "foo\nbar" } it 'detects the line' do @@ -85,7 +85,7 @@ end end - context 'matches line - line exists' do + context 'when matches line - line exists' do let(:params) { { :match => '^foo' } } let(:content) { "foo\nbar" } @@ -94,7 +94,7 @@ end end - context 'matches line - line does not exist' do + context 'when matches line - line does not exist' do let(:params) { { :match => '^foo' } } let(:content) { "foo bar\nbar" } diff --git a/spec/unit/puppet/provider/file_line/ruby_spec_alter.rb b/spec/unit/puppet/provider/file_line/ruby_spec_alter.rb index 316c5c080..84e1add81 100755 --- a/spec/unit/puppet/provider/file_line/ruby_spec_alter.rb +++ b/spec/unit/puppet/provider/file_line/ruby_spec_alter.rb @@ -163,8 +163,8 @@ provider_class.new(resource) end - context 'match and after set' do - shared_context 'resource_create' do + context 'when match and after set' do + shared_context 'when resource_create' do let(:match) { '^foo2$' } let(:after) { '^foo1$' } let(:resource) do diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 0ae7f51f9..0fc10fea6 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -72,10 +72,10 @@ expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, %r{line is a required attribute}) end it 'does not require that a line is specified when matching for absence' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Lint/BooleanSymbol, Metrics/LineLength end it 'although if a line is specified anyway when matching for absence it still works and the line is silently ignored' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Lint/BooleanSymbol, Metrics/LineLength end it 'requires that a file is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, %r{path is a required attribute}) @@ -84,7 +84,7 @@ expect(file_line[:ensure]).to eq :present end it 'defaults to replace => true' do - expect(file_line[:replace]).to eq :true + expect(file_line[:replace]).to eq :true # rubocop:disable Lint/BooleanSymbol end it 'defaults to encoding => UTF-8' do expect(file_line[:encoding]).to eq 'UTF-8'