diff options
278 files changed, 872 insertions, 521 deletions
@@ -1,15 +1,27 @@ #This file is generated by ModuleSync, do not edit. pkg/ Gemfile.lock +Gemfile.local vendor/ spec/fixtures/manifests/ spec/fixtures/modules/ +log/ +junit/ .vagrant/ .bundle/ coverage/ log/ .idea/ +.metadata *.iml +.*.sw[op] +.yardoc +.yardwarns +.DS_Store +tmp/ +vendor/ +doc/ + !spec/fixtures/ spec/fixtures/manifests/site.pp spec/fixtures/modules/* @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <projectDescription> - <name>stdlib</name> + <name>puppetlabs-stdlib</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> - <name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name> + <name>com.puppetlabs.geppetto.pp.dsl.ui.modulefileBuilder</name> <arguments> </arguments> </buildCommand> @@ -17,7 +17,7 @@ </buildCommand> </buildSpec> <natures> - <nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature> + <nature>com.puppetlabs.geppetto.pp.dsl.ui.puppetNature</nature> <nature>org.eclipse.xtext.ui.shared.xtextNature</nature> </natures> </projectDescription> @@ -1,4 +1,6 @@ --- +NOTICE: + unmanaged: true .gitignore: paths: - '!spec/fixtures/' diff --git a/.travis.yml b/.travis.yml index d972387..4981b25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false language: ruby cache: bundler -script: "bundle exec rake validate lint spec" +script: "bundle exec rake release_checks" #Inserting below due to the following issue: https://github.com/travis-ci/travis-ci/issues/3531#issuecomment-88311203 before_install: - gem update bundler @@ -25,17 +25,8 @@ matrix: - rvm: 2.3.1 bundler_args: --without system_tests env: PUPPET_GEM_VERSION="~> 4.0" - - rvm: 2.1.9 + - rvm: 2.1.7 bundler_args: --without system_tests env: PUPPET_GEM_VERSION="~> 4.0" - - rvm: 2.1.5 - bundler_args: --without system_tests - env: PUPPET_GEM_VERSION="~> 3.0" FUTURE_PARSER="yes" - - rvm: 2.1.5 - bundler_args: --without system_tests - env: PUPPET_GEM_VERSION="~> 3.0" - - rvm: 1.9.3 - bundler_args: --without system_tests - env: PUPPET_GEM_VERSION="~> 3.0" notifications: email: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3c3f1e7..990edba 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,7 @@ Checklist (and a short version for the impatient) - Make sure you have a [GitHub account](https://github.com/join) - - [Create a ticket](https://tickets.puppetlabs.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppetlabs.com/browse/) you are patching for. + - [Create a ticket](https://tickets.puppet.com/secure/CreateIssue!default.jspa), or [watch the ticket](https://tickets.puppet.com/browse/) you are patching for. * Preferred method: @@ -215,4 +215,3 @@ Additional Resources * [General GitHub documentation](http://help.github.com/) * [GitHub pull request documentation](http://help.github.com/send-pull-requests/) - @@ -49,16 +49,15 @@ group :development do gem 'json_pure', '<= 2.0.1', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') gem 'fast_gettext', '1.1.0', :require => false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') gem 'fast_gettext', :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') + gem 'rainbow', '< 2.2.0', :require => false end group :system_tests do - gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '~> 2.20') if supports_windows - gem 'beaker', *location_for(ENV['BEAKER_VERSION']) if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0') and ! supports_windows - gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '< 3') if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.3.0') and ! supports_windows - gem 'beaker-pe', :require => false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0') - gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '>= 3.4') if ! supports_windows - gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION'] || '~> 5.1') if supports_windows + gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || '>= 3') + gem 'beaker-pe', :require => false + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION']) gem 'beaker-puppet_install_helper', :require => false + gem 'beaker-module_install_helper', :require => false gem 'master_manipulator', :require => false gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) gem 'beaker-abs', *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') diff --git a/MAINTAINERS.md b/MAINTAINERS.md new file mode 100644 index 0000000..e8004a5 --- /dev/null +++ b/MAINTAINERS.md @@ -0,0 +1,6 @@ +## Maintenance + +Maintainers: + - Puppet Forge Modules Team `forge-modules |at| puppet |dot| com` + +Tickets: https://tickets.puppet.com/browse/MODULES. Make sure to set component to `stdlib`. diff --git a/README.markdown b/README.markdown index a4c30b5..4eca785 100644 --- a/README.markdown +++ b/README.markdown @@ -118,6 +118,22 @@ In this code example, `match` looks for a line beginning with export followed by HTTP_PROXY and delete it. If multiple lines match, an error will be raised unless the `multiple => true` parameter is set. +Encoding example: + + file_line { "XScreenSaver": + ensure => present, + path => '/root/XScreenSaver' + line => "*lock: 10:00:00", + match => '^*lock:', + encoding => "iso-8859-1", + } + +Files with special characters that are not valid UTF-8 will give the +error message "invalid byte sequence in UTF-8". In this case, determine +the correct file encoding and specify the correct encoding using the +encoding attribute, the value of which needs to be a valid Ruby character +encoding. + **Autorequires:** If Puppet is managing the file that contains the line being managed, the `file_line` resource autorequires that file. ##### Parameters @@ -815,6 +831,10 @@ The return value is an array in which each element is one joined key/value pair. Returns the keys of a hash as an array. *Type*: rvalue. +#### `length` + +Returns the length of a given string, array or hash. To eventually replace the deprecated size() function as can handle the new type functionality introduced in Puppet 4. *Type*: rvalue. + #### `loadyaml` Loads a YAML file containing an array, string, or hash, and returns the data in the corresponding native data type. @@ -1067,7 +1087,7 @@ Randomizes the order of a string or array elements. *Type*: rvalue. #### `size` -Returns the number of elements in a string, an array or a hash. *Type*: rvalue. +Returns the number of elements in a string, an array or a hash. May get confused around Puppet 4 type values and as such is to be deprecated in the next release and replaced with the new stdlib length function. *Type*: rvalue. #### `sort` @@ -1,10 +1,9 @@ -require 'puppet_blacksmith/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' +require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? +PuppetLint.configuration.fail_on_warnings = true PuppetLint.configuration.send('relative') -PuppetLint.configuration.send('disable_documentation') -PuppetLint.configuration.send('disable_single_quote_string_with_variables') desc 'Generate pooler nodesets' task :gen_nodeset do diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..c87ed7c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,40 @@ +version: 1.1.x.{build} +skip_commits: + message: /^\(?doc\)?.*/ +clone_depth: 10 +init: +- SET +- 'mkdir C:\ProgramData\PuppetLabs\code && exit 0' +- 'mkdir C:\ProgramData\PuppetLabs\facter && exit 0' +- 'mkdir C:\ProgramData\PuppetLabs\hiera && exit 0' +- 'mkdir C:\ProgramData\PuppetLabs\puppet\var && exit 0' +environment: + matrix: + - PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VER: 21 + - PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VER: 21-x64 + - PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VER: 23 + - PUPPET_GEM_VERSION: ~> 4.0 + RUBY_VER: 23-x64 + - PUPPET_GEM_VERSION: 4.2.3 + RUBY_VER: 21-x64 +matrix: + fast_finish: true +install: +- SET PATH=C:\Ruby%RUBY_VER%\bin;%PATH% +- bundle install --jobs 4 --retry 2 --without system_tests +- type Gemfile.lock +build: off +test_script: +- bundle exec puppet -V +- ruby -v +- bundle exec rake spec SPEC_OPTS='--format documentation' +notifications: +- provider: Email + to: + - nobody@nowhere.com + on_build_success: false + on_build_failure: false + on_build_status_changed: false diff --git a/lib/puppet/functions/length.rb b/lib/puppet/functions/length.rb new file mode 100644 index 0000000..86e735c --- /dev/null +++ b/lib/puppet/functions/length.rb @@ -0,0 +1,14 @@ +#A function to eventually replace the old size() function for stdlib - The original size function did not handle Puppets new type capabilities, so this function is a Puppet 4 compatible solution. +Puppet::Functions.create_function(:length) do + dispatch :length do + param 'Variant[String,Array,Hash]', :value + end + def length(value) + if value.is_a?(String) + result = value.length + elsif value.is_a?(Array) || value.is_a?(Hash) + result = value.size + end + return result + end +end diff --git a/lib/puppet/parser/functions/abs.rb b/lib/puppet/parser/functions/abs.rb index 11d2d7f..222a902 100644 --- a/lib/puppet/parser/functions/abs.rb +++ b/lib/puppet/parser/functions/abs.rb @@ -9,8 +9,7 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "abs(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "abs(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] @@ -21,8 +20,7 @@ module Puppet::Parser::Functions elsif value.match(/^-?\d+$/) value = value.to_i else - raise(Puppet::ParseError, 'abs(): Requires float or ' + - 'integer to work with') + raise(Puppet::ParseError, 'abs(): Requires float or integer to work with') end end diff --git a/lib/puppet/parser/functions/any2bool.rb b/lib/puppet/parser/functions/any2bool.rb index f0f8f83..17612bf 100644 --- a/lib/puppet/parser/functions/any2bool.rb +++ b/lib/puppet/parser/functions/any2bool.rb @@ -15,8 +15,7 @@ This converts 'anything' to a boolean. In practise it does the following: EOS ) do |arguments| - raise(Puppet::ParseError, "any2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "any2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 # If argument is already Boolean, return it if !!arguments[0] == arguments[0] diff --git a/lib/puppet/parser/functions/assert_private.rb b/lib/puppet/parser/functions/assert_private.rb index 66c79cc..62e2c6b 100644 --- a/lib/puppet/parser/functions/assert_private.rb +++ b/lib/puppet/parser/functions/assert_private.rb @@ -9,8 +9,7 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, "assert_private(): Wrong number of arguments "+ - "given (#{args.size}}) for 0 or 1)") if args.size > 1 + raise(Puppet::ParseError, "assert_private(): Wrong number of arguments given (#{args.size}}) for 0 or 1)") if args.size > 1 scope = self if scope.lookupvar('module_name') != scope.lookupvar('caller_module_name') diff --git a/lib/puppet/parser/functions/bool2num.rb b/lib/puppet/parser/functions/bool2num.rb index 6ad6cf4..92e4dde 100644 --- a/lib/puppet/parser/functions/bool2num.rb +++ b/lib/puppet/parser/functions/bool2num.rb @@ -11,8 +11,7 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "bool2num(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = function_str2bool([arguments[0]]) diff --git a/lib/puppet/parser/functions/bool2str.rb b/lib/puppet/parser/functions/bool2str.rb index 7e36474..37d4a4e 100644 --- a/lib/puppet/parser/functions/bool2str.rb +++ b/lib/puppet/parser/functions/bool2str.rb @@ -20,8 +20,7 @@ module Puppet::Parser::Functions ) do |arguments| unless arguments.size == 1 or arguments.size == 3 - raise(Puppet::ParseError, "bool2str(): Wrong number of arguments " + - "given (#{arguments.size} for 3)") + raise(Puppet::ParseError, "bool2str(): Wrong number of arguments given (#{arguments.size} for 3)") end value = arguments[0] diff --git a/lib/puppet/parser/functions/camelcase.rb b/lib/puppet/parser/functions/camelcase.rb index d7f43f7..dd67915 100644 --- a/lib/puppet/parser/functions/camelcase.rb +++ b/lib/puppet/parser/functions/camelcase.rb @@ -8,15 +8,13 @@ Converts the case of a string or all strings in an array to camel case. EOS ) do |arguments| - raise(Puppet::ParseError, "camelcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "camelcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] klass = value.class unless [Array, String].include?(klass) - raise(Puppet::ParseError, 'camelcase(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'camelcase(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/capitalize.rb b/lib/puppet/parser/functions/capitalize.rb index 98b2d16..08f1c30 100644 --- a/lib/puppet/parser/functions/capitalize.rb +++ b/lib/puppet/parser/functions/capitalize.rb @@ -9,14 +9,12 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "capitalize(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'capitalize(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'capitalize(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/ceiling.rb b/lib/puppet/parser/functions/ceiling.rb index 5f3b10b..bec4266 100644 --- a/lib/puppet/parser/functions/ceiling.rb +++ b/lib/puppet/parser/functions/ceiling.rb @@ -5,18 +5,15 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "ceiling(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "ceiling(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 begin arg = Float(arguments[0]) rescue TypeError, ArgumentError => e - raise(Puppet::ParseError, "ceiling(): Wrong argument type " + - "given (#{arguments[0]} for Numeric)") + raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arguments[0]} for Numeric)") end - raise(Puppet::ParseError, "ceiling(): Wrong argument type " + - "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false + raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false arg.ceil end diff --git a/lib/puppet/parser/functions/chomp.rb b/lib/puppet/parser/functions/chomp.rb index c55841e..f9da50f 100644 --- a/lib/puppet/parser/functions/chomp.rb +++ b/lib/puppet/parser/functions/chomp.rb @@ -10,14 +10,12 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "chomp(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "chomp(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'chomp(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'chomp(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/chop.rb b/lib/puppet/parser/functions/chop.rb index b24ab78..809349d 100644 --- a/lib/puppet/parser/functions/chop.rb +++ b/lib/puppet/parser/functions/chop.rb @@ -12,14 +12,12 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "chop(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "chop(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'chop(): Requires either an ' + - 'array or string to work with') + raise(Puppet::ParseError, 'chop(): Requires either an array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/clamp.rb b/lib/puppet/parser/functions/clamp.rb index 432c7c1..c4503fe 100644 --- a/lib/puppet/parser/functions/clamp.rb +++ b/lib/puppet/parser/functions/clamp.rb @@ -10,8 +10,7 @@ module Puppet::Parser::Functions args.flatten! - raise(Puppet::ParseError, 'clamp(): Wrong number of arguments, ' + - 'need three to clamp') if args.size != 3 + raise(Puppet::ParseError, 'clamp(): Wrong number of arguments, need three to clamp') if args.size != 3 # check values out args.each do |value| diff --git a/lib/puppet/parser/functions/concat.rb b/lib/puppet/parser/functions/concat.rb index 91edb4e..0a49cfe 100644 --- a/lib/puppet/parser/functions/concat.rb +++ b/lib/puppet/parser/functions/concat.rb @@ -17,8 +17,7 @@ Would result in: ) do |arguments| # Check that more than 2 arguments have been given ... - raise(Puppet::ParseError, "concat(): Wrong number of arguments " + - "given (#{arguments.size} for < 2)") if arguments.size < 2 + raise(Puppet::ParseError, "concat(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2 a = arguments[0] diff --git a/lib/puppet/parser/functions/count.rb b/lib/puppet/parser/functions/count.rb index 52de1b8..cef2637 100644 --- a/lib/puppet/parser/functions/count.rb +++ b/lib/puppet/parser/functions/count.rb @@ -7,8 +7,7 @@ If called with only an array it counts the number of elements that are not nil/u ) do |args| if (args.size > 2) then - raise(ArgumentError, "count(): Wrong number of arguments "+ - "given #{args.size} for 1 or 2.") + raise(ArgumentError, "count(): Wrong number of arguments given #{args.size} for 1 or 2.") end collection, item = args diff --git a/lib/puppet/parser/functions/delete.rb b/lib/puppet/parser/functions/delete.rb index 466c55c..9dd5164 100644 --- a/lib/puppet/parser/functions/delete.rb +++ b/lib/puppet/parser/functions/delete.rb @@ -23,8 +23,7 @@ string, or key from a hash. EOS ) do |arguments| - raise(Puppet::ParseError, "delete(): Wrong number of arguments "+ - "given #{arguments.size} for 2") unless arguments.size == 2 + raise(Puppet::ParseError, "delete(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2 collection = arguments[0].dup Array(arguments[1]).each do |item| @@ -34,8 +33,7 @@ string, or key from a hash. when String collection.gsub! item, '' else - raise(TypeError, "delete(): First argument must be an Array, " + - "String, or Hash. Given an argument of class #{collection.class}.") + raise(TypeError, "delete(): First argument must be an Array, String, or Hash. Given an argument of class #{collection.class}.") end end collection diff --git a/lib/puppet/parser/functions/delete_at.rb b/lib/puppet/parser/functions/delete_at.rb index 3eb4b53..daf3721 100644 --- a/lib/puppet/parser/functions/delete_at.rb +++ b/lib/puppet/parser/functions/delete_at.rb @@ -14,8 +14,7 @@ Would return: ['a','c'] EOS ) do |arguments| - raise(Puppet::ParseError, "delete_at(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 + raise(Puppet::ParseError, "delete_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 array = arguments[0] @@ -26,8 +25,7 @@ Would return: ['a','c'] index = arguments[1] if index.is_a?(String) and not index.match(/^\d+$/) - raise(Puppet::ParseError, 'delete_at(): You must provide ' + - 'non-negative numeric index') + raise(Puppet::ParseError, 'delete_at(): You must provide non-negative numeric index') end result = array.clone @@ -36,8 +34,7 @@ Would return: ['a','c'] index = index.to_i if index > result.size - 1 # First element is at index 0 is it not? - raise(Puppet::ParseError, 'delete_at(): Given index ' + - 'exceeds size of array given') + raise(Puppet::ParseError, 'delete_at(): Given index exceeds size of array given') end result.delete_at(index) # We ignore the element that got deleted ... diff --git a/lib/puppet/parser/functions/delete_regex.rb b/lib/puppet/parser/functions/delete_regex.rb index d72b3e9..e2c32db 100644 --- a/lib/puppet/parser/functions/delete_regex.rb +++ b/lib/puppet/parser/functions/delete_regex.rb @@ -12,7 +12,7 @@ to be matched as an OR. delete_regex(['a','b','c','b'], 'b') Would return: ['a','c'] - + delete_regex(['a','b','c','b'], ['b', 'c']) Would return: ['a'] @@ -25,8 +25,7 @@ to be matched as an OR. EOS ) do |arguments| - raise(Puppet::ParseError, "delete_regex(): Wrong number of arguments "+ - "given #{arguments.size} for 2") unless arguments.size == 2 + raise(Puppet::ParseError, "delete_regex(): Wrong number of arguments given #{arguments.size} for 2") unless arguments.size == 2 collection = arguments[0].dup Array(arguments[1]).each do |item| @@ -34,8 +33,7 @@ to be matched as an OR. when Array, Hash, String collection.reject! { |coll_item| (coll_item =~ %r{\b#{item}\b}) } else - raise(TypeError, "delete_regex(): First argument must be an Array, " + - "Hash, or String. Given an argument of class #{collection.class}.") + raise(TypeError, "delete_regex(): First argument must be an Array, Hash, or String. Given an argument of class #{collection.class}.") end end collection diff --git a/lib/puppet/parser/functions/delete_undef_values.rb b/lib/puppet/parser/functions/delete_undef_values.rb index f94d4da..00bd252 100644 --- a/lib/puppet/parser/functions/delete_undef_values.rb +++ b/lib/puppet/parser/functions/delete_undef_values.rb @@ -15,13 +15,10 @@ Would return: ['A','',false] EOS ) do |args| - raise(Puppet::ParseError, - "delete_undef_values(): Wrong number of arguments given " + - "(#{args.size})") if args.size < 1 + raise(Puppet::ParseError, "delete_undef_values(): Wrong number of arguments given (#{args.size})") if args.size < 1 unless args[0].is_a? Array or args[0].is_a? Hash - raise(Puppet::ParseError, - "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ") + raise(Puppet::ParseError, "delete_undef_values(): expected an array or hash, got #{args[0]} type #{args[0].class} ") end result = args[0].dup if result.is_a?(Hash) diff --git a/lib/puppet/parser/functions/delete_values.rb b/lib/puppet/parser/functions/delete_values.rb index f6c8c0e..e799aef 100644 --- a/lib/puppet/parser/functions/delete_values.rb +++ b/lib/puppet/parser/functions/delete_values.rb @@ -11,15 +11,12 @@ Would return: {'a'=>'A','c'=>'C','B'=>'D'} EOS ) do |arguments| - raise(Puppet::ParseError, - "delete_values(): Wrong number of arguments given " + - "(#{arguments.size} of 2)") if arguments.size != 2 + raise(Puppet::ParseError, "delete_values(): Wrong number of arguments given (#{arguments.size} of 2)") if arguments.size != 2 hash, item = arguments if not hash.is_a?(Hash) - raise(TypeError, "delete_values(): First argument must be a Hash. " + \ - "Given an argument of class #{hash.class}.") + raise(TypeError, "delete_values(): First argument must be a Hash. Given an argument of class #{hash.class}.") end hash.dup.delete_if { |key, val| item == val } end diff --git a/lib/puppet/parser/functions/deprecation.rb b/lib/puppet/parser/functions/deprecation.rb index cd64fe2..39d306a 100644 --- a/lib/puppet/parser/functions/deprecation.rb +++ b/lib/puppet/parser/functions/deprecation.rb @@ -4,8 +4,7 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "deprecation: Wrong number of arguments " + - "given (#{arguments.size} for 2)") unless arguments.size == 2 + raise(Puppet::ParseError, "deprecation: Wrong number of arguments given (#{arguments.size} for 2)") unless arguments.size == 2 key = arguments[0] message = arguments[1] diff --git a/lib/puppet/parser/functions/difference.rb b/lib/puppet/parser/functions/difference.rb index cd258f7..c9ac478 100644 --- a/lib/puppet/parser/functions/difference.rb +++ b/lib/puppet/parser/functions/difference.rb @@ -17,8 +17,7 @@ Would return: ["a"] ) do |arguments| # Two arguments are required - raise(Puppet::ParseError, "difference(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 + raise(Puppet::ParseError, "difference(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2 first = arguments[0] second = arguments[1] diff --git a/lib/puppet/parser/functions/dig44.rb b/lib/puppet/parser/functions/dig44.rb index 1e7c318..21c0a8c 100644 --- a/lib/puppet/parser/functions/dig44.rb +++ b/lib/puppet/parser/functions/dig44.rb @@ -42,19 +42,16 @@ missing. And the fourth argument can set a variable path separator. eos ) 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 + raise(Puppet::ParseError, "dig44(): Wrong number of arguments given (#{arguments.size} for at least 2)") if arguments.size < 2 data, path, default = *arguments unless data.is_a?(Hash) or data.is_a?(Array) - raise(Puppet::ParseError, "dig44(): first argument must be a hash or an array, " << - "given #{data.class.name}") + raise(Puppet::ParseError, "dig44(): first argument must be a hash or an array, given #{data.class.name}") end unless path.is_a? Array - raise(Puppet::ParseError, "dig44(): second argument must be an array, " << - "given #{path.class.name}") + raise(Puppet::ParseError, "dig44(): second argument must be an array, given #{path.class.name}") end value = path.reduce(data) do |structure, key| diff --git a/lib/puppet/parser/functions/downcase.rb b/lib/puppet/parser/functions/downcase.rb index 040b84f..7a16afc 100644 --- a/lib/puppet/parser/functions/downcase.rb +++ b/lib/puppet/parser/functions/downcase.rb @@ -8,14 +8,12 @@ Converts the case of a string or all strings in an array to lower case. EOS ) do |arguments| - raise(Puppet::ParseError, "downcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "downcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'downcase(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'downcase(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/empty.rb b/lib/puppet/parser/functions/empty.rb index b5a3cde..4f77ad3 100644 --- a/lib/puppet/parser/functions/empty.rb +++ b/lib/puppet/parser/functions/empty.rb @@ -8,14 +8,12 @@ Returns true if the variable is empty. EOS ) do |arguments| - raise(Puppet::ParseError, "empty(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "empty(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(Hash) || value.is_a?(String) || value.is_a?(Numeric) - raise(Puppet::ParseError, 'empty(): Requires either ' + - 'array, hash, string or integer to work with') + raise(Puppet::ParseError, 'empty(): Requires either array, hash, string or integer to work with') end if value.is_a?(Numeric) diff --git a/lib/puppet/parser/functions/enclose_ipv6.rb b/lib/puppet/parser/functions/enclose_ipv6.rb index 80ffc3a..1f8a454 100644 --- a/lib/puppet/parser/functions/enclose_ipv6.rb +++ b/lib/puppet/parser/functions/enclose_ipv6.rb @@ -16,12 +16,10 @@ Takes an array of ip addresses and encloses the ipv6 addresses with square brack end if (arguments.size != 1) then - raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "enclose_ipv6(): Wrong number of arguments given #{arguments.size} for 1") end unless arguments[0].is_a?(String) or arguments[0].is_a?(Array) then - raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type "+ - "given #{arguments[0].class} expected String or Array") + raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument type given #{arguments[0].class} expected String or Array") end input = [arguments[0]].flatten.compact @@ -32,8 +30,7 @@ Takes an array of ip addresses and encloses the ipv6 addresses with square brack begin ip = IPAddr.new(val) rescue *rescuable_exceptions - raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument "+ - "given #{val} is not an ip address.") + raise(Puppet::ParseError, "enclose_ipv6(): Wrong argument given #{val} is not an ip address.") end val = "[#{ip.to_s}]" if ip.ipv6? end diff --git a/lib/puppet/parser/functions/ensure_packages.rb b/lib/puppet/parser/functions/ensure_packages.rb index 439af1e..17942b8 100644 --- a/lib/puppet/parser/functions/ensure_packages.rb +++ b/lib/puppet/parser/functions/ensure_packages.rb @@ -11,9 +11,8 @@ third argument to the ensure_resource() function. ) do |arguments| if arguments.size > 2 or arguments.size == 0 - raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments " + - "given (#{arguments.size} for 1 or 2)") - elsif arguments.size == 2 and !arguments[1].is_a?(Hash) + raise(Puppet::ParseError, "ensure_packages(): Wrong number of arguments given (#{arguments.size} for 1 or 2)") + elsif arguments.size == 2 and !arguments[1].is_a?(Hash) raise(Puppet::ParseError, 'ensure_packages(): Requires second argument to be a Hash') end @@ -37,7 +36,9 @@ third argument to the ensure_resource() function. Puppet::Parser::Functions.function(:ensure_resource) packages.each { |package_name| + if !findresource("Package[#{package_name}]") function_ensure_resource(['package', package_name, defaults ]) + end } end end diff --git a/lib/puppet/parser/functions/flatten.rb b/lib/puppet/parser/functions/flatten.rb index a1ed183..4401bdb 100644 --- a/lib/puppet/parser/functions/flatten.rb +++ b/lib/puppet/parser/functions/flatten.rb @@ -15,8 +15,7 @@ Would return: ['a','b','c'] EOS ) do |arguments| - raise(Puppet::ParseError, "flatten(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "flatten(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 array = arguments[0] diff --git a/lib/puppet/parser/functions/floor.rb b/lib/puppet/parser/functions/floor.rb index 9a6f014..9e4b504 100644 --- a/lib/puppet/parser/functions/floor.rb +++ b/lib/puppet/parser/functions/floor.rb @@ -5,18 +5,15 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "floor(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "floor(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 begin arg = Float(arguments[0]) rescue TypeError, ArgumentError => e - raise(Puppet::ParseError, "floor(): Wrong argument type " + - "given (#{arguments[0]} for Numeric)") + raise(Puppet::ParseError, "floor(): Wrong argument type given (#{arguments[0]} for Numeric)") end - raise(Puppet::ParseError, "floor(): Wrong argument type " + - "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false + raise(Puppet::ParseError, "floor(): Wrong argument type given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false arg.floor end diff --git a/lib/puppet/parser/functions/fqdn_rotate.rb b/lib/puppet/parser/functions/fqdn_rotate.rb index b66431d..05bdcc7 100644 --- a/lib/puppet/parser/functions/fqdn_rotate.rb +++ b/lib/puppet/parser/functions/fqdn_rotate.rb @@ -15,15 +15,13 @@ Puppet::Parser::Functions.newfunction( result will be the same every time unless its hostname changes.) Adding a SEED can be useful if you need more than one unrelated rotation.") do |args| - raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size < 1 + raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1 value = args.shift require 'digest/md5' unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'fqdn_rotate(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'fqdn_rotate(): Requires either array or string to work with') end result = value.clone diff --git a/lib/puppet/parser/functions/grep.rb b/lib/puppet/parser/functions/grep.rb index ceba9ec..c611a7e 100644 --- a/lib/puppet/parser/functions/grep.rb +++ b/lib/puppet/parser/functions/grep.rb @@ -18,8 +18,7 @@ Would return: ) do |arguments| if (arguments.size != 2) then - raise(Puppet::ParseError, "grep(): Wrong number of arguments "+ - "given #{arguments.size} for 2") + raise(Puppet::ParseError, "grep(): Wrong number of arguments given #{arguments.size} for 2") end a = arguments[0] diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb index e762798..f6cb74b 100644 --- a/lib/puppet/parser/functions/has_interface_with.rb +++ b/lib/puppet/parser/functions/has_interface_with.rb @@ -19,8 +19,7 @@ has_interface_with("lo") => true EOS ) do |args| - raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments " + - "given (#{args.size} for 1 or 2)") if args.size < 1 or args.size > 2 + raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments given (#{args.size} for 1 or 2)") if args.size < 1 or args.size > 2 interfaces = lookupvar('interfaces') diff --git a/lib/puppet/parser/functions/has_ip_address.rb b/lib/puppet/parser/functions/has_ip_address.rb index 842c8ec..a0071c8 100644 --- a/lib/puppet/parser/functions/has_ip_address.rb +++ b/lib/puppet/parser/functions/has_ip_address.rb @@ -11,8 +11,7 @@ This function iterates through the 'interfaces' fact and checks the EOS ) do |args| - raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 + raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1 Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) diff --git a/lib/puppet/parser/functions/has_ip_network.rb b/lib/puppet/parser/functions/has_ip_network.rb index 9ccf902..b02c0c0 100644 --- a/lib/puppet/parser/functions/has_ip_network.rb +++ b/lib/puppet/parser/functions/has_ip_network.rb @@ -11,8 +11,7 @@ This function iterates through the 'interfaces' fact and checks the EOS ) do |args| - raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size != 1 + raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1 Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) diff --git a/lib/puppet/parser/functions/hash.rb b/lib/puppet/parser/functions/hash.rb index 89d0e07..22763f3 100644 --- a/lib/puppet/parser/functions/hash.rb +++ b/lib/puppet/parser/functions/hash.rb @@ -14,8 +14,7 @@ Would return: {'a'=>1,'b'=>2,'c'=>3} EOS ) do |arguments| - raise(Puppet::ParseError, "hash(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 array = arguments[0] @@ -30,8 +29,7 @@ Would return: {'a'=>1,'b'=>2,'c'=>3} array = array.flatten result = Hash[*array] rescue StandardError - raise(Puppet::ParseError, 'hash(): Unable to compute ' + - 'hash from array given') + raise(Puppet::ParseError, 'hash(): Unable to compute hash from array given') end return result diff --git a/lib/puppet/parser/functions/intersection.rb b/lib/puppet/parser/functions/intersection.rb index bfbb4ba..8a438f4 100644 --- a/lib/puppet/parser/functions/intersection.rb +++ b/lib/puppet/parser/functions/intersection.rb @@ -15,8 +15,7 @@ This function returns an array of the intersection of two. ) do |arguments| # Two arguments are required - raise(Puppet::ParseError, "intersection(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size != 2 + raise(Puppet::ParseError, "intersection(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size != 2 first = arguments[0] second = arguments[1] diff --git a/lib/puppet/parser/functions/is_array.rb b/lib/puppet/parser/functions/is_array.rb index 1d2c0fa..a33afe4 100644 --- a/lib/puppet/parser/functions/is_array.rb +++ b/lib/puppet/parser/functions/is_array.rb @@ -10,8 +10,7 @@ Returns true if the variable passed to this function is an array. function_deprecation([:is_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.']) - raise(Puppet::ParseError, "is_array(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "is_array(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 type = arguments[0] diff --git a/lib/puppet/parser/functions/is_bool.rb b/lib/puppet/parser/functions/is_bool.rb index 83d2ebe..2ebe430 100644 --- a/lib/puppet/parser/functions/is_bool.rb +++ b/lib/puppet/parser/functions/is_bool.rb @@ -10,8 +10,7 @@ Returns true if the variable passed to this function is a boolean. function_deprecation([:is_bool, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Bool. There is further documentation for validate_legacy function in the README.']) - raise(Puppet::ParseError, "is_bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "is_bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 type = arguments[0] diff --git a/lib/puppet/parser/functions/is_domain_name.rb b/lib/puppet/parser/functions/is_domain_name.rb index 90ede32..247db3b 100644 --- a/lib/puppet/parser/functions/is_domain_name.rb +++ b/lib/puppet/parser/functions/is_domain_name.rb @@ -9,8 +9,7 @@ Returns true if the string passed to this function is a syntactically correct do ) do |arguments| if (arguments.size != 1) then - raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_domain_name(): Wrong number of arguments given #{arguments.size} for 1") end # Only allow string types diff --git a/lib/puppet/parser/functions/is_email_address.rb b/lib/puppet/parser/functions/is_email_address.rb index 4fb0229..bcd7921 100644 --- a/lib/puppet/parser/functions/is_email_address.rb +++ b/lib/puppet/parser/functions/is_email_address.rb @@ -8,8 +8,7 @@ Returns true if the string passed to this function is a valid email address. EOS ) do |arguments| if arguments.size != 1 - raise(Puppet::ParseError, 'is_email_address(): Wrong number of arguments '\ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_email_address(): Wrong number of arguments given #{arguments.size} for 1") end # Taken from http://emailregex.com/ (simpler regex) diff --git a/lib/puppet/parser/functions/is_float.rb b/lib/puppet/parser/functions/is_float.rb index 1186458..aa84a2b 100644 --- a/lib/puppet/parser/functions/is_float.rb +++ b/lib/puppet/parser/functions/is_float.rb @@ -11,8 +11,7 @@ Returns true if the variable passed to this function is a float. function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.']) if (arguments.size != 1) then - raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_float(): Wrong number of arguments given #{arguments.size} for 1") end value = arguments[0] diff --git a/lib/puppet/parser/functions/is_function_available.rb b/lib/puppet/parser/functions/is_function_available.rb index 6da82c8..50cd5e1 100644 --- a/lib/puppet/parser/functions/is_function_available.rb +++ b/lib/puppet/parser/functions/is_function_available.rb @@ -11,8 +11,7 @@ true if the function exists, false if not. ) do |arguments| if (arguments.size != 1) then - raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_function_available?(): Wrong number of arguments given #{arguments.size} for 1") end # Only allow String types diff --git a/lib/puppet/parser/functions/is_hash.rb b/lib/puppet/parser/functions/is_hash.rb index ad907f0..3162f7d 100644 --- a/lib/puppet/parser/functions/is_hash.rb +++ b/lib/puppet/parser/functions/is_hash.rb @@ -8,8 +8,7 @@ Returns true if the variable passed to this function is a hash. EOS ) do |arguments| - raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "is_hash(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 type = arguments[0] diff --git a/lib/puppet/parser/functions/is_integer.rb b/lib/puppet/parser/functions/is_integer.rb index e04fd1f..8965b15 100644 --- a/lib/puppet/parser/functions/is_integer.rb +++ b/lib/puppet/parser/functions/is_integer.rb @@ -16,8 +16,7 @@ If given any other argument `false` is returned. function_deprecation([:is_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.']) if (arguments.size != 1) then - raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_integer(): Wrong number of arguments given #{arguments.size} for 1") end value = arguments[0] diff --git a/lib/puppet/parser/functions/is_ip_address.rb b/lib/puppet/parser/functions/is_ip_address.rb index 5f1d765..79ddb98 100644 --- a/lib/puppet/parser/functions/is_ip_address.rb +++ b/lib/puppet/parser/functions/is_ip_address.rb @@ -13,8 +13,7 @@ Returns true if the string passed to this function is a valid IP address. function_deprecation([:is_ip_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ip_address. There is further documentation for validate_legacy function in the README.']) if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_ip_address(): Wrong number of arguments given #{arguments.size} for 1") end begin diff --git a/lib/puppet/parser/functions/is_ipv4_address.rb b/lib/puppet/parser/functions/is_ipv4_address.rb index 1764e61..91869b6 100644 --- a/lib/puppet/parser/functions/is_ipv4_address.rb +++ b/lib/puppet/parser/functions/is_ipv4_address.rb @@ -13,8 +13,7 @@ Returns true if the string passed to this function is a valid IPv4 address. function_deprecation([:is_ipv4_address, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Ipv4. There is further documentation for validate_legacy function in the README.']) if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ipv4_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_ipv4_address(): Wrong number of arguments given #{arguments.size} for 1") end begin diff --git a/lib/puppet/parser/functions/is_ipv6_address.rb b/lib/puppet/parser/functions/is_ipv6_address.rb index 7ca4997..4d96202 100644 --- a/lib/puppet/parser/functions/is_ipv6_address.rb +++ b/lib/puppet/parser/functions/is_ipv6_address.rb @@ -13,8 +13,7 @@ Returns true if the string passed to this function is a valid IPv6 address. require 'ipaddr' if (arguments.size != 1) then - raise(Puppet::ParseError, "is_ipv6_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_ipv6_address(): Wrong number of arguments given #{arguments.size} for 1") end begin diff --git a/lib/puppet/parser/functions/is_mac_address.rb b/lib/puppet/parser/functions/is_mac_address.rb index 2619d44..5993ed2 100644 --- a/lib/puppet/parser/functions/is_mac_address.rb +++ b/lib/puppet/parser/functions/is_mac_address.rb @@ -9,8 +9,7 @@ Returns true if the string passed to this function is a valid mac address. ) do |arguments| if (arguments.size != 1) then - raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments given #{arguments.size} for 1") end mac = arguments[0] diff --git a/lib/puppet/parser/functions/is_numeric.rb b/lib/puppet/parser/functions/is_numeric.rb index 4a55225..7800edd 100644 --- a/lib/puppet/parser/functions/is_numeric.rb +++ b/lib/puppet/parser/functions/is_numeric.rb @@ -27,8 +27,7 @@ Valid examples: function_deprecation([:is_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.']) if (arguments.size != 1) then - raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments given #{arguments.size} for 1") end value = arguments[0] diff --git a/lib/puppet/parser/functions/is_string.rb b/lib/puppet/parser/functions/is_string.rb index 31ee91e..0ed6aec 100644 --- a/lib/puppet/parser/functions/is_string.rb +++ b/lib/puppet/parser/functions/is_string.rb @@ -10,8 +10,7 @@ Returns true if the variable passed to this function is a string. function_deprecation([:is_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.']) - raise(Puppet::ParseError, "is_string(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "is_string(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 type = arguments[0] diff --git a/lib/puppet/parser/functions/join.rb b/lib/puppet/parser/functions/join.rb index 6c0a6ba..1c17997 100644 --- a/lib/puppet/parser/functions/join.rb +++ b/lib/puppet/parser/functions/join.rb @@ -15,8 +15,7 @@ Would result in: "a,b,c" ) do |arguments| # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "join(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 array = arguments[0] diff --git a/lib/puppet/parser/functions/join_keys_to_values.rb b/lib/puppet/parser/functions/join_keys_to_values.rb index e3baf9f..d8966ba 100644 --- a/lib/puppet/parser/functions/join_keys_to_values.rb +++ b/lib/puppet/parser/functions/join_keys_to_values.rb @@ -23,22 +23,19 @@ Would result in: ["a is 1","b is 2","b is 3"] # Validate the number of arguments. if arguments.size != 2 - raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two " + - "arguments, but #{arguments.size} given.") + raise(Puppet::ParseError, "join_keys_to_values(): Takes exactly two arguments, but #{arguments.size} given.") end # Validate the first argument. hash = arguments[0] if not hash.is_a?(Hash) - raise(TypeError, "join_keys_to_values(): The first argument must be a " + - "hash, but a #{hash.class} was given.") + raise(TypeError, "join_keys_to_values(): The first argument must be a hash, but a #{hash.class} was given.") end # Validate the second argument. separator = arguments[1] if not separator.is_a?(String) - raise(TypeError, "join_keys_to_values(): The second argument must be a " + - "string, but a #{separator.class} was given.") + raise(TypeError, "join_keys_to_values(): The second argument must be a string, but a #{separator.class} was given.") end # Join the keys to their values. diff --git a/lib/puppet/parser/functions/keys.rb b/lib/puppet/parser/functions/keys.rb index f0d13b6..199e319 100644 --- a/lib/puppet/parser/functions/keys.rb +++ b/lib/puppet/parser/functions/keys.rb @@ -8,8 +8,7 @@ Returns the keys of a hash as an array. EOS ) do |arguments| - raise(Puppet::ParseError, "keys(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "keys(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 hash = arguments[0] diff --git a/lib/puppet/parser/functions/lstrip.rb b/lib/puppet/parser/functions/lstrip.rb index 624e4c8..9a9ee29 100644 --- a/lib/puppet/parser/functions/lstrip.rb +++ b/lib/puppet/parser/functions/lstrip.rb @@ -8,14 +8,12 @@ Strips leading spaces to the left of a string. EOS ) do |arguments| - raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "lstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'lstrip(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'lstrip(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/max.rb b/lib/puppet/parser/functions/max.rb index 60fb94a..758c42c 100644 --- a/lib/puppet/parser/functions/max.rb +++ b/lib/puppet/parser/functions/max.rb @@ -5,8 +5,7 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, "max(): Wrong number of arguments " + - "need at least one") if args.size == 0 + raise(Puppet::ParseError, "max(): Wrong number of arguments need at least one") if args.size == 0 # Sometimes we get numbers as numerics and sometimes as strings. # We try to compare them as numbers when possible diff --git a/lib/puppet/parser/functions/member.rb b/lib/puppet/parser/functions/member.rb index 1e5b3de..fb93452 100644 --- a/lib/puppet/parser/functions/member.rb +++ b/lib/puppet/parser/functions/member.rb @@ -30,8 +30,7 @@ would return: false EOS ) do |arguments| - raise(Puppet::ParseError, "member(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 + raise(Puppet::ParseError, "member(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 array = arguments[0] @@ -50,8 +49,7 @@ would return: false end - raise(Puppet::ParseError, 'member(): You must provide item ' + - 'to search for within array given') if item.respond_to?('empty?') && item.empty? + raise(Puppet::ParseError, 'member(): You must provide item to search for within array given') if item.respond_to?('empty?') && item.empty? result = (item - array).empty? diff --git a/lib/puppet/parser/functions/min.rb b/lib/puppet/parser/functions/min.rb index 6bd6ebf..f10a2b2 100644 --- a/lib/puppet/parser/functions/min.rb +++ b/lib/puppet/parser/functions/min.rb @@ -5,8 +5,7 @@ module Puppet::Parser::Functions EOS ) do |args| - raise(Puppet::ParseError, "min(): Wrong number of arguments " + - "need at least one") if args.size == 0 + raise(Puppet::ParseError, "min(): Wrong number of arguments need at least one") if args.size == 0 # Sometimes we get numbers as numerics and sometimes as strings. # We try to compare them as numbers when possible diff --git a/lib/puppet/parser/functions/num2bool.rb b/lib/puppet/parser/functions/num2bool.rb index af0e6ed..9ad59b2 100644 --- a/lib/puppet/parser/functions/num2bool.rb +++ b/lib/puppet/parser/functions/num2bool.rb @@ -10,8 +10,7 @@ become true. EOS ) do |arguments| - raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 number = arguments[0] diff --git a/lib/puppet/parser/functions/prefix.rb b/lib/puppet/parser/functions/prefix.rb index ac1c58a..b1c1e35 100644 --- a/lib/puppet/parser/functions/prefix.rb +++ b/lib/puppet/parser/functions/prefix.rb @@ -15,8 +15,7 @@ Will return: ['pa','pb','pc'] ) do |arguments| # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "prefix(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "prefix(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 enumerable = arguments[0] diff --git a/lib/puppet/parser/functions/range.rb b/lib/puppet/parser/functions/range.rb index d690df7..72c373a 100644 --- a/lib/puppet/parser/functions/range.rb +++ b/lib/puppet/parser/functions/range.rb @@ -37,8 +37,7 @@ Will return: [0,2,4,6,8] EOS ) do |arguments| - raise(Puppet::ParseError, 'range(): Wrong number of ' + - 'arguments given (0 for 1)') if arguments.size == 0 + raise(Puppet::ParseError, 'range(): Wrong number of arguments given (0 for 1)') if arguments.size == 0 if arguments.size > 1 start = arguments[0] @@ -57,8 +56,7 @@ Will return: [0,2,4,6,8] type = m[2] step = 1 elsif value.match(/^.+$/) - raise(Puppet::ParseError, "range(): Unable to compute range " + - "from the value: #{value}") + raise(Puppet::ParseError, "range(): Unable to compute range from the value: #{value}") else raise(Puppet::ParseError, "range(): Unknown range format: #{value}") end diff --git a/lib/puppet/parser/functions/regexpescape.rb b/lib/puppet/parser/functions/regexpescape.rb index 477ee87..2cfa3bb 100644 --- a/lib/puppet/parser/functions/regexpescape.rb +++ b/lib/puppet/parser/functions/regexpescape.rb @@ -7,14 +7,12 @@ module Puppet::Parser::Functions Requires either a single string or an array as an input. EOS ) do |arguments| # rubocop:disable Style/ClosingParenthesisIndentation - raise(Puppet::ParseError, 'regexpescape(): Wrong number of arguments ' \ - "given (#{arguments.size} for 1)") if arguments.empty? + raise(Puppet::ParseError, "regexpescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty? value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'regexpescape(): Requires either ' \ - 'array or string to work with') + raise(Puppet::ParseError, 'regexpescape(): Requires either array or string to work with') end result = if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/reverse.rb b/lib/puppet/parser/functions/reverse.rb index 7f1018f..aca98ce 100644 --- a/lib/puppet/parser/functions/reverse.rb +++ b/lib/puppet/parser/functions/reverse.rb @@ -8,14 +8,12 @@ Reverses the order of a string or array. EOS ) do |arguments| - raise(Puppet::ParseError, "reverse(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "reverse(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'reverse(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'reverse(): Requires either array or string to work with') end result = value.reverse diff --git a/lib/puppet/parser/functions/rstrip.rb b/lib/puppet/parser/functions/rstrip.rb index 0cf8d22..e24abd5 100644 --- a/lib/puppet/parser/functions/rstrip.rb +++ b/lib/puppet/parser/functions/rstrip.rb @@ -8,14 +8,12 @@ Strips leading spaces to the right of the string. EOS ) do |arguments| - raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "rstrip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'rstrip(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'rstrip(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/shell_escape.rb b/lib/puppet/parser/functions/shell_escape.rb index 447fe35..7306b7c 100644 --- a/lib/puppet/parser/functions/shell_escape.rb +++ b/lib/puppet/parser/functions/shell_escape.rb @@ -15,8 +15,7 @@ This function behaves the same as ruby's Shellwords.shellescape() function. EOS ) do |arguments| - raise(Puppet::ParseError, "shell_escape(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "shell_escape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 # explicit conversion to string is required for ruby 1.9 string = arguments[0].to_s diff --git a/lib/puppet/parser/functions/shell_join.rb b/lib/puppet/parser/functions/shell_join.rb index 05aeb95..682ed8d 100644 --- a/lib/puppet/parser/functions/shell_join.rb +++ b/lib/puppet/parser/functions/shell_join.rb @@ -13,8 +13,7 @@ This function behaves the same as ruby's Shellwords.shelljoin() function EOS ) do |arguments| - raise(Puppet::ParseError, "shell_join(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "shell_join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 array = arguments[0] diff --git a/lib/puppet/parser/functions/shell_split.rb b/lib/puppet/parser/functions/shell_split.rb index 0446448..09e6e78 100644 --- a/lib/puppet/parser/functions/shell_split.rb +++ b/lib/puppet/parser/functions/shell_split.rb @@ -12,8 +12,7 @@ This function behaves the same as ruby's Shellwords.shellsplit() function EOS ) do |arguments| - raise(Puppet::ParseError, "shell_split(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "shell_split(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 string = arguments[0].to_s diff --git a/lib/puppet/parser/functions/shuffle.rb b/lib/puppet/parser/functions/shuffle.rb index 30c663d..942cbce 100644 --- a/lib/puppet/parser/functions/shuffle.rb +++ b/lib/puppet/parser/functions/shuffle.rb @@ -8,14 +8,12 @@ Randomizes the order of a string or array elements. EOS ) do |arguments| - raise(Puppet::ParseError, "shuffle(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "shuffle(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'shuffle(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'shuffle(): Requires either array or string to work with') end result = value.clone diff --git a/lib/puppet/parser/functions/size.rb b/lib/puppet/parser/functions/size.rb index 0d6cc96..b503aa0 100644 --- a/lib/puppet/parser/functions/size.rb +++ b/lib/puppet/parser/functions/size.rb @@ -8,11 +8,12 @@ Returns the number of elements in a string, an array or a hash EOS ) do |arguments| - raise(Puppet::ParseError, "size(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 item = arguments[0] + function_deprecation([:size, 'This method is going to be deprecated, please use the stdlib length function.']) + if item.is_a?(String) begin @@ -26,8 +27,7 @@ Returns the number of elements in a string, an array or a hash # Float(item) - raise(Puppet::ParseError, 'size(): Requires either ' + - 'string, array or hash to work with') + raise(Puppet::ParseError, 'size(): Requires either string, array or hash to work with') rescue ArgumentError result = item.size diff --git a/lib/puppet/parser/functions/sort.rb b/lib/puppet/parser/functions/sort.rb index cefbe54..7c8a1c9 100644 --- a/lib/puppet/parser/functions/sort.rb +++ b/lib/puppet/parser/functions/sort.rb @@ -9,8 +9,7 @@ Sorts strings and arrays lexically. ) do |arguments| if (arguments.size != 1) then - raise(Puppet::ParseError, "sort(): Wrong number of arguments "+ - "given #{arguments.size} for 1") + raise(Puppet::ParseError, "sort(): Wrong number of arguments given #{arguments.size} for 1") end value = arguments[0] diff --git a/lib/puppet/parser/functions/squeeze.rb b/lib/puppet/parser/functions/squeeze.rb index 81fadfd..f5757d1 100644 --- a/lib/puppet/parser/functions/squeeze.rb +++ b/lib/puppet/parser/functions/squeeze.rb @@ -9,8 +9,7 @@ Returns a new string where runs of the same character that occur in this set are ) do |arguments| if ((arguments.size != 2) and (arguments.size != 1)) then - raise(Puppet::ParseError, "squeeze(): Wrong number of arguments "+ - "given #{arguments.size} for 2 or 1") + raise(Puppet::ParseError, "squeeze(): Wrong number of arguments given #{arguments.size} for 2 or 1") end item = arguments[0] diff --git a/lib/puppet/parser/functions/str2bool.rb b/lib/puppet/parser/functions/str2bool.rb index 472506d..38ad1ce 100644 --- a/lib/puppet/parser/functions/str2bool.rb +++ b/lib/puppet/parser/functions/str2bool.rb @@ -10,8 +10,7 @@ like: 0, F,f, N,n, false, FALSE, no to 'false'. EOS ) do |arguments| - raise(Puppet::ParseError, "str2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "str2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 string = arguments[0] @@ -21,8 +20,7 @@ like: 0, F,f, N,n, false, FALSE, no to 'false'. end unless string.is_a?(String) - raise(Puppet::ParseError, 'str2bool(): Requires ' + - 'string to work with') + raise(Puppet::ParseError, 'str2bool(): Requires string to work with') end # We consider all the yes, no, y, n and so on too ... diff --git a/lib/puppet/parser/functions/str2saltedsha512.rb b/lib/puppet/parser/functions/str2saltedsha512.rb index 7fe7b01..7e98d9f 100644 --- a/lib/puppet/parser/functions/str2saltedsha512.rb +++ b/lib/puppet/parser/functions/str2saltedsha512.rb @@ -12,14 +12,12 @@ manifests as a valid password attribute. ) do |arguments| require 'digest/sha2' - raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments " + - "passed (#{arguments.size} but we require 1)") if arguments.size != 1 + raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments passed (#{arguments.size} but we require 1)") if arguments.size != 1 password = arguments[0] unless password.is_a?(String) - raise(Puppet::ParseError, 'str2saltedsha512(): Requires a ' + - "String argument, you passed: #{password.class}") + raise(Puppet::ParseError, "str2saltedsha512(): Requires a String argument, you passed: #{password.class}") end seedint = rand(2**31 - 1) diff --git a/lib/puppet/parser/functions/strftime.rb b/lib/puppet/parser/functions/strftime.rb index 0b52ade..f0dc5cf 100644 --- a/lib/puppet/parser/functions/strftime.rb +++ b/lib/puppet/parser/functions/strftime.rb @@ -71,13 +71,11 @@ To return the date: ) do |arguments| # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "strftime(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "strftime(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 format = arguments[0] - raise(Puppet::ParseError, 'strftime(): You must provide ' + - 'format for evaluation') if format.empty? + raise(Puppet::ParseError, 'strftime(): You must provide format for evaluation') if format.empty? # The Time Zone argument is optional ... time_zone = arguments[1] if arguments[1] diff --git a/lib/puppet/parser/functions/strip.rb b/lib/puppet/parser/functions/strip.rb index 3fac47d..9e8366f 100644 --- a/lib/puppet/parser/functions/strip.rb +++ b/lib/puppet/parser/functions/strip.rb @@ -15,14 +15,12 @@ Would result in: "aaa" EOS ) do |arguments| - raise(Puppet::ParseError, "strip(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'strip(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'strip(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/suffix.rb b/lib/puppet/parser/functions/suffix.rb index 2908434..7c5057d 100644 --- a/lib/puppet/parser/functions/suffix.rb +++ b/lib/puppet/parser/functions/suffix.rb @@ -16,8 +16,7 @@ Will return: ['ap','bp','cp'] ) do |arguments| # Technically we support two arguments but only first is mandatory ... - raise(Puppet::ParseError, "suffix(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "suffix(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 enumerable = arguments[0] diff --git a/lib/puppet/parser/functions/swapcase.rb b/lib/puppet/parser/functions/swapcase.rb index eb7fe13..8158f3c 100644 --- a/lib/puppet/parser/functions/swapcase.rb +++ b/lib/puppet/parser/functions/swapcase.rb @@ -14,14 +14,12 @@ Would result in: "AbCd" EOS ) do |arguments| - raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "swapcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'swapcase(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'swapcase(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/time.rb b/lib/puppet/parser/functions/time.rb index c574747..d7780c8 100644 --- a/lib/puppet/parser/functions/time.rb +++ b/lib/puppet/parser/functions/time.rb @@ -18,8 +18,7 @@ Will return something like: 1311972653 time_zone = arguments[0] if arguments[0] if (arguments.size != 0) and (arguments.size != 1) then - raise(Puppet::ParseError, "time(): Wrong number of arguments "+ - "given #{arguments.size} for 0 or 1") + raise(Puppet::ParseError, "time(): Wrong number of arguments given #{arguments.size} for 0 or 1") end time = Time.new diff --git a/lib/puppet/parser/functions/to_bytes.rb b/lib/puppet/parser/functions/to_bytes.rb index df490ea..bf72503 100644 --- a/lib/puppet/parser/functions/to_bytes.rb +++ b/lib/puppet/parser/functions/to_bytes.rb @@ -7,8 +7,7 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 arg = arguments[0] diff --git a/lib/puppet/parser/functions/type3x.rb b/lib/puppet/parser/functions/type3x.rb index 0800b4a..b17380e 100644 --- a/lib/puppet/parser/functions/type3x.rb +++ b/lib/puppet/parser/functions/type3x.rb @@ -16,8 +16,7 @@ Returns the type when passed a value. Type can be one of: * boolean EOS ) do |args| - raise(Puppet::ParseError, "type3x(): Wrong number of arguments " + - "given (#{args.size} for 1)") if args.size < 1 + raise(Puppet::ParseError, "type3x(): Wrong number of arguments given (#{args.size} for 1)") if args.size < 1 value = args[0] diff --git a/lib/puppet/parser/functions/union.rb b/lib/puppet/parser/functions/union.rb index 6c5bb83..abe2dc8 100644 --- a/lib/puppet/parser/functions/union.rb +++ b/lib/puppet/parser/functions/union.rb @@ -15,8 +15,7 @@ Would return: ["a","b","c","d"] ) do |arguments| # Check that 2 or more arguments have been given ... - raise(Puppet::ParseError, "union(): Wrong number of arguments " + - "given (#{arguments.size} for < 2)") if arguments.size < 2 + raise(Puppet::ParseError, "union(): Wrong number of arguments given (#{arguments.size} for < 2)") if arguments.size < 2 arguments.each do |argument| raise(Puppet::ParseError, 'union(): Every parameter must be an array') unless argument.is_a?(Array) diff --git a/lib/puppet/parser/functions/unique.rb b/lib/puppet/parser/functions/unique.rb index cf770f3..b57431d 100644 --- a/lib/puppet/parser/functions/unique.rb +++ b/lib/puppet/parser/functions/unique.rb @@ -24,14 +24,12 @@ This returns: EOS ) do |arguments| - raise(Puppet::ParseError, "unique(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "unique(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'unique(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'unique(): Requires either array or string to work with') end result = value.clone diff --git a/lib/puppet/parser/functions/upcase.rb b/lib/puppet/parser/functions/upcase.rb index 44b3bcd..9f09110 100644 --- a/lib/puppet/parser/functions/upcase.rb +++ b/lib/puppet/parser/functions/upcase.rb @@ -16,14 +16,12 @@ Will return: EOS ) do |arguments| - raise(Puppet::ParseError, "upcase(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "upcase(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:upcase) - raise(Puppet::ParseError, 'upcase(): Requires an ' + - 'array, hash or object that responds to upcase in order to work') + raise(Puppet::ParseError, 'upcase(): Requires an array, hash or object that responds to upcase in order to work') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/uriescape.rb b/lib/puppet/parser/functions/uriescape.rb index 45bbed2..8296d8b 100644 --- a/lib/puppet/parser/functions/uriescape.rb +++ b/lib/puppet/parser/functions/uriescape.rb @@ -10,14 +10,12 @@ module Puppet::Parser::Functions EOS ) do |arguments| - raise(Puppet::ParseError, "uriescape(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "uriescape(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 value = arguments[0] unless value.is_a?(Array) || value.is_a?(String) - raise(Puppet::ParseError, 'uriescape(): Requires either ' + - 'array or string to work with') + raise(Puppet::ParseError, 'uriescape(): Requires either array or string to work with') end if value.is_a?(Array) diff --git a/lib/puppet/parser/functions/values.rb b/lib/puppet/parser/functions/values.rb index 1606756..0ca236c 100644 --- a/lib/puppet/parser/functions/values.rb +++ b/lib/puppet/parser/functions/values.rb @@ -21,8 +21,7 @@ This example would return: EOS ) do |arguments| - raise(Puppet::ParseError, "values(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size < 1 + raise(Puppet::ParseError, "values(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1 hash = arguments[0] diff --git a/lib/puppet/parser/functions/values_at.rb b/lib/puppet/parser/functions/values_at.rb index f350f53..04a3d1a 100644 --- a/lib/puppet/parser/functions/values_at.rb +++ b/lib/puppet/parser/functions/values_at.rb @@ -29,8 +29,7 @@ Would return ['a','c','d']. EOS ) do |arguments| - raise(Puppet::ParseError, "values_at(): Wrong number of " + - "arguments given (#{arguments.size} for 2)") if arguments.size < 2 + raise(Puppet::ParseError, "values_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 array = arguments.shift @@ -41,8 +40,7 @@ Would return ['a','c','d']. indices = [arguments.shift].flatten() # Get them all ... Pokemon ... if not indices or indices.empty? - raise(Puppet::ParseError, 'values_at(): You must provide ' + - 'at least one positive index to collect') + raise(Puppet::ParseError, 'values_at(): You must provide at least one positive index to collect') end result = [] @@ -57,11 +55,9 @@ Would return ['a','c','d']. type = m[2] if start > stop - raise(Puppet::ParseError, 'values_at(): Stop index in ' + - 'given indices range is smaller than the start index') + raise(Puppet::ParseError, 'values_at(): Stop index in given indices range is smaller than the start index') elsif stop > array.size - 1 # First element is at index 0 is it not? - raise(Puppet::ParseError, 'values_at(): Stop index in ' + - 'given indices range exceeds array size') + raise(Puppet::ParseError, 'values_at(): Stop index in given indices range exceeds array size') end range = case type @@ -73,16 +69,14 @@ Would return ['a','c','d']. else # Only positive numbers allowed in this case ... if not i.match(/^\d+$/) - raise(Puppet::ParseError, 'values_at(): Unknown format ' + - 'of given index') + raise(Puppet::ParseError, 'values_at(): Unknown format of given index') end # In Puppet numbers are often string-encoded ... i = i.to_i if i > array.size - 1 # Same story. First element is at index 0 ... - raise(Puppet::ParseError, 'values_at(): Given index ' + - 'exceeds array size') + raise(Puppet::ParseError, 'values_at(): Given index exceeds array size') end indices_list << i diff --git a/lib/puppet/parser/functions/zip.rb b/lib/puppet/parser/functions/zip.rb index 3074f28..13e24b6 100644 --- a/lib/puppet/parser/functions/zip.rb +++ b/lib/puppet/parser/functions/zip.rb @@ -17,8 +17,7 @@ Would result in: ) do |arguments| # Technically we support three arguments but only first is mandatory ... - raise(Puppet::ParseError, "zip(): Wrong number of arguments " + - "given (#{arguments.size} for 2)") if arguments.size < 2 + raise(Puppet::ParseError, "zip(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2 a = arguments[0] b = arguments[1] diff --git a/lib/puppet/provider/file_line/ruby.rb b/lib/puppet/provider/file_line/ruby.rb index beeb430..fbf7d8e 100644 --- a/lib/puppet/provider/file_line/ruby.rb +++ b/lib/puppet/provider/file_line/ruby.rb @@ -40,7 +40,7 @@ Puppet::Type.type(:file_line).provide(:ruby) do # file; for now assuming that this type is only used on # small-ish config files that can fit into memory without # too much trouble. - @lines ||= File.readlines(resource[:path]) + @lines ||= File.readlines(resource[:path], :encoding => resource[:encoding]) end def match_regex diff --git a/lib/puppet/type/file_line.rb b/lib/puppet/type/file_line.rb index 7b7d44e..e82b246 100644 --- a/lib/puppet/type/file_line.rb +++ b/lib/puppet/type/file_line.rb @@ -48,6 +48,22 @@ Puppet::Type.newtype(:file_line) do followed by HTTP_PROXY and delete it. If multiple lines match, an error will be raised unless the `multiple => true` parameter is set. + Encoding example: + + file_line { "XScreenSaver": + ensure => present, + path => '/root/XScreenSaver' + line => "*lock: 10:00:00", + match => '^*lock:', + encoding => "iso-8859-1", + } + + Files with special characters that are not valid UTF-8 will give the + error message "invalid byte sequence in UTF-8". In this case, determine + the correct file encoding and specify the correct encoding using the + encoding attribute, the value of which needs to be a valid Ruby character + encoding. + **Autorequires:** If Puppet is managing the file that will contain the line being managed, the file_line resource will autorequire that file. EOT @@ -107,6 +123,11 @@ Puppet::Type.newtype(:file_line) do defaultto true end + newparam(:encoding) do + desc 'For files that are not UTF-8 encoded, specify encoding such as iso-8859-1' + defaultto 'UTF-8' + end + # Autorequire the file resource if it's being managed autorequire(:file) do self[:path] diff --git a/spec/acceptance/abs_spec.rb b/spec/acceptance/abs_spec.rb index 6e41e2f..5af436f 100755 --- a/spec/acceptance/abs_spec.rb +++ b/spec/acceptance/abs_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'abs function' do describe 'success' do it 'should accept a string' do pp = <<-EOS diff --git a/spec/acceptance/anchor_spec.rb b/spec/acceptance/anchor_spec.rb index 5bc2bbb..24a9064 100755 --- a/spec/acceptance/anchor_spec.rb +++ b/spec/acceptance/anchor_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_acceptance' -describe 'anchor type', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'anchor type' do describe 'success' do it 'should effect proper chaining of resources' do pp = <<-EOS diff --git a/spec/acceptance/any2array_spec.rb b/spec/acceptance/any2array_spec.rb index 18ea4cd..8a13911 100755 --- a/spec/acceptance/any2array_spec.rb +++ b/spec/acceptance/any2array_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'any2array function' do describe 'success' do it 'should create an empty array' do pp = <<-EOS diff --git a/spec/acceptance/base64_spec.rb b/spec/acceptance/base64_spec.rb index 97e1738..e9096a7 100755 --- a/spec/acceptance/base64_spec.rb +++ b/spec/acceptance/base64_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'base64 function' do describe 'success' do it 'should encode then decode a string' do pp = <<-EOS diff --git a/spec/acceptance/bool2num_spec.rb b/spec/acceptance/bool2num_spec.rb index 52ff75b..c69acc6 100755 --- a/spec/acceptance/bool2num_spec.rb +++ b/spec/acceptance/bool2num_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'bool2num function' do describe 'success' do ['false', 'f', '0', 'n', 'no'].each do |bool| it "should convert a given boolean, #{bool}, to 0" do diff --git a/spec/acceptance/capitalize_spec.rb b/spec/acceptance/capitalize_spec.rb index e5e7b7b..03d01a8 100755 --- a/spec/acceptance/capitalize_spec.rb +++ b/spec/acceptance/capitalize_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'capitalize function' do describe 'success' do it 'should capitalize the first letter of a string' do pp = <<-EOS diff --git a/spec/acceptance/ceiling_spec.rb b/spec/acceptance/ceiling_spec.rb index 557986e..895e4a0 100755 --- a/spec/acceptance/ceiling_spec.rb +++ b/spec/acceptance/ceiling_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'ceiling function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'ceiling function' do describe 'success' do it 'ceilings floats' do pp = <<-EOS diff --git a/spec/acceptance/chomp_spec.rb b/spec/acceptance/chomp_spec.rb index f6c1595..56e0876 100755 --- a/spec/acceptance/chomp_spec.rb +++ b/spec/acceptance/chomp_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'chomp function' do describe 'success' do it 'should eat the newline' do pp = <<-EOS diff --git a/spec/acceptance/chop_spec.rb b/spec/acceptance/chop_spec.rb index a16a710..0993806 100755 --- a/spec/acceptance/chop_spec.rb +++ b/spec/acceptance/chop_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'chop function' do describe 'success' do it 'should eat the last character' do pp = <<-EOS diff --git a/spec/acceptance/clamp_spec.rb b/spec/acceptance/clamp_spec.rb index 0189258..e8ccb96 100755 --- a/spec/acceptance/clamp_spec.rb +++ b/spec/acceptance/clamp_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'clamp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'clamp function' do describe 'success' do it 'clamps list of values' do pp = <<-EOS diff --git a/spec/acceptance/concat_spec.rb b/spec/acceptance/concat_spec.rb index c472db6..8d184d1 100755 --- a/spec/acceptance/concat_spec.rb +++ b/spec/acceptance/concat_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'concat function' do describe 'success' do it 'should concat one array to another' do pp = <<-EOS diff --git a/spec/acceptance/count_spec.rb b/spec/acceptance/count_spec.rb index fe7ca9d..18c039d 100755 --- a/spec/acceptance/count_spec.rb +++ b/spec/acceptance/count_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'count function' do describe 'success' do it 'should count elements in an array' do pp = <<-EOS diff --git a/spec/acceptance/deep_merge_spec.rb b/spec/acceptance/deep_merge_spec.rb index c0f9b12..8222f24 100755 --- a/spec/acceptance/deep_merge_spec.rb +++ b/spec/acceptance/deep_merge_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'deep_merge function' do describe 'success' do it 'should deep merge two hashes' do pp = <<-EOS diff --git a/spec/acceptance/defined_with_params_spec.rb b/spec/acceptance/defined_with_params_spec.rb index fc54450..a332bd6 100755 --- a/spec/acceptance/defined_with_params_spec.rb +++ b/spec/acceptance/defined_with_params_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'defined_with_params function' do describe 'success' do it 'should successfully notify' do pp = <<-EOS diff --git a/spec/acceptance/delete_at_spec.rb b/spec/acceptance/delete_at_spec.rb index db0c01f..d4f852a 100755 --- a/spec/acceptance/delete_at_spec.rb +++ b/spec/acceptance/delete_at_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete_at function' do describe 'success' do it 'should delete elements of the array' do pp = <<-EOS diff --git a/spec/acceptance/delete_spec.rb b/spec/acceptance/delete_spec.rb index a28604c..f85b093 100755 --- a/spec/acceptance/delete_spec.rb +++ b/spec/acceptance/delete_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete function' do describe 'success' do it 'should delete elements of the array' do pp = <<-EOS diff --git a/spec/acceptance/delete_undef_values_spec.rb b/spec/acceptance/delete_undef_values_spec.rb index b7eda19..af45a92 100755 --- a/spec/acceptance/delete_undef_values_spec.rb +++ b/spec/acceptance/delete_undef_values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete_undef_values function' do describe 'success' do it 'should delete elements of the array' do pp = <<-EOS diff --git a/spec/acceptance/delete_values_spec.rb b/spec/acceptance/delete_values_spec.rb index 6d2369c..04b6920 100755 --- a/spec/acceptance/delete_values_spec.rb +++ b/spec/acceptance/delete_values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'delete_values function' do describe 'success' do it 'should delete elements of the hash' do pp = <<-EOS diff --git a/spec/acceptance/difference_spec.rb b/spec/acceptance/difference_spec.rb index 2fae5c4..68f6bbe 100755 --- a/spec/acceptance/difference_spec.rb +++ b/spec/acceptance/difference_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'difference function' do describe 'success' do it 'returns non-duplicates in the first array' do pp = <<-EOS diff --git a/spec/acceptance/dirname_spec.rb b/spec/acceptance/dirname_spec.rb index 97913dd..db83f0f 100755 --- a/spec/acceptance/dirname_spec.rb +++ b/spec/acceptance/dirname_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'dirname function' do describe 'success' do context 'absolute path' do it 'returns the dirname' do diff --git a/spec/acceptance/downcase_spec.rb b/spec/acceptance/downcase_spec.rb index bc4e706..300bcfa 100755 --- a/spec/acceptance/downcase_spec.rb +++ b/spec/acceptance/downcase_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'downcase function' do describe 'success' do it 'returns the downcase' do pp = <<-EOS diff --git a/spec/acceptance/empty_spec.rb b/spec/acceptance/empty_spec.rb index 2d4df90..97b7333 100755 --- a/spec/acceptance/empty_spec.rb +++ b/spec/acceptance/empty_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'empty function' do describe 'success' do it 'recognizes empty strings' do pp = <<-EOS diff --git a/spec/acceptance/flatten_spec.rb b/spec/acceptance/flatten_spec.rb index c4d66e0..289eec9 100755 --- a/spec/acceptance/flatten_spec.rb +++ b/spec/acceptance/flatten_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'flatten function' do describe 'success' do it 'flattens arrays' do pp = <<-EOS diff --git a/spec/acceptance/floor_spec.rb b/spec/acceptance/floor_spec.rb index 0dcdad9..8259d2a 100755 --- a/spec/acceptance/floor_spec.rb +++ b/spec/acceptance/floor_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'floor function' do describe 'success' do it 'floors floats' do pp = <<-EOS diff --git a/spec/acceptance/fqdn_rand_string_spec.rb b/spec/acceptance/fqdn_rand_string_spec.rb index 065a517..af1b2a9 100644 --- a/spec/acceptance/fqdn_rand_string_spec.rb +++ b/spec/acceptance/fqdn_rand_string_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'fqdn_rand_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'fqdn_rand_string function' do describe 'success' do include_context "with faked facts" context "when the FQDN is 'fakehost.localdomain'" do diff --git a/spec/acceptance/fqdn_rotate_spec.rb b/spec/acceptance/fqdn_rotate_spec.rb index 404351f..66e94a9 100755 --- a/spec/acceptance/fqdn_rotate_spec.rb +++ b/spec/acceptance/fqdn_rotate_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'fqdn_rotate function' do describe 'success' do include_context "with faked facts" context "when the FQDN is 'fakehost.localdomain'" do diff --git a/spec/acceptance/get_module_path_spec.rb b/spec/acceptance/get_module_path_spec.rb index 6ac690c..3d10251 100755 --- a/spec/acceptance/get_module_path_spec.rb +++ b/spec/acceptance/get_module_path_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'get_module_path function' do describe 'success' do it 'get_module_paths dne' do pp = <<-EOS diff --git a/spec/acceptance/getparam_spec.rb b/spec/acceptance/getparam_spec.rb index b1a677e..bd12154 100755 --- a/spec/acceptance/getparam_spec.rb +++ b/spec/acceptance/getparam_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'getparam function' do describe 'success' do it 'getparam a notify' do pp = <<-EOS diff --git a/spec/acceptance/getvar_spec.rb b/spec/acceptance/getvar_spec.rb index 333c467..605cdce 100755 --- a/spec/acceptance/getvar_spec.rb +++ b/spec/acceptance/getvar_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'getvar function' do describe 'success' do it 'getvars from classes' do pp = <<-EOS diff --git a/spec/acceptance/grep_spec.rb b/spec/acceptance/grep_spec.rb index b39d48e..7c35ee4 100755 --- a/spec/acceptance/grep_spec.rb +++ b/spec/acceptance/grep_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'grep function' do describe 'success' do it 'greps arrays' do pp = <<-EOS diff --git a/spec/acceptance/has_interface_with_spec.rb b/spec/acceptance/has_interface_with_spec.rb index 9590193..fd33af5 100755 --- a/spec/acceptance/has_interface_with_spec.rb +++ b/spec/acceptance/has_interface_with_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_interface_with function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do +describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do describe 'success' do it 'has_interface_with existing ipaddress' do pp = <<-EOS diff --git a/spec/acceptance/has_ip_address_spec.rb b/spec/acceptance/has_ip_address_spec.rb index 149a10d..878d921 100755 --- a/spec/acceptance/has_ip_address_spec.rb +++ b/spec/acceptance/has_ip_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_ip_address function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do +describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do describe 'success' do it 'has_ip_address existing ipaddress' do pp = <<-EOS diff --git a/spec/acceptance/has_ip_network_spec.rb b/spec/acceptance/has_ip_network_spec.rb index 7d2f34e..f7a7d35 100755 --- a/spec/acceptance/has_ip_network_spec.rb +++ b/spec/acceptance/has_ip_network_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_ip_network function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do +describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') or (fact('osfamily') == 'AIX')) do describe 'success' do it 'has_ip_network existing ipaddress' do pp = <<-EOS diff --git a/spec/acceptance/has_key_spec.rb b/spec/acceptance/has_key_spec.rb index c8557cb..661c122 100755 --- a/spec/acceptance/has_key_spec.rb +++ b/spec/acceptance/has_key_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'has_key function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'has_key function' do describe 'success' do it 'has_keys in hashes' do pp = <<-EOS diff --git a/spec/acceptance/hash_spec.rb b/spec/acceptance/hash_spec.rb index ed53834..85da50b 100755 --- a/spec/acceptance/hash_spec.rb +++ b/spec/acceptance/hash_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'hash function' do describe 'success' do it 'hashs arrays' do pp = <<-EOS diff --git a/spec/acceptance/intersection_spec.rb b/spec/acceptance/intersection_spec.rb index 66b8652..02d4e7d 100755 --- a/spec/acceptance/intersection_spec.rb +++ b/spec/acceptance/intersection_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'intersection function' do describe 'success' do it 'intersections arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_a_spec.rb b/spec/acceptance/is_a_spec.rb index 355fd83..fb0019a 100644 --- a/spec/acceptance/is_a_spec.rb +++ b/spec/acceptance/is_a_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' if get_puppet_version =~ /^4/ - describe 'is_a function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do + describe 'is_a function' do it 'should match a string' do pp = <<-EOS if 'hello world'.is_a(String) { diff --git a/spec/acceptance/is_array_spec.rb b/spec/acceptance/is_array_spec.rb index 9c6bad7..1a83417 100755 --- a/spec/acceptance/is_array_spec.rb +++ b/spec/acceptance/is_array_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_array function' do describe 'success' do it 'is_arrays arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_bool_spec.rb b/spec/acceptance/is_bool_spec.rb index 60079f9..823cb46 100755 --- a/spec/acceptance/is_bool_spec.rb +++ b/spec/acceptance/is_bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_bool function' do describe 'success' do it 'is_bools arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_domain_name_spec.rb b/spec/acceptance/is_domain_name_spec.rb index e0f03fa..884b0bc 100755 --- a/spec/acceptance/is_domain_name_spec.rb +++ b/spec/acceptance/is_domain_name_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_domain_name function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_domain_name function' do describe 'success' do it 'is_domain_names arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_float_spec.rb b/spec/acceptance/is_float_spec.rb index 338ba58..0b38d94 100755 --- a/spec/acceptance/is_float_spec.rb +++ b/spec/acceptance/is_float_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_float function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_float function' do describe 'success' do it 'is_floats arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_function_available_spec.rb b/spec/acceptance/is_function_available_spec.rb index 2b5dd6d..f8191ee 100755 --- a/spec/acceptance/is_function_available_spec.rb +++ b/spec/acceptance/is_function_available_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_function_available function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_function_available function' do describe 'success' do it 'is_function_availables arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_hash_spec.rb b/spec/acceptance/is_hash_spec.rb index 2ef310a..64f016c 100755 --- a/spec/acceptance/is_hash_spec.rb +++ b/spec/acceptance/is_hash_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_hash function' do describe 'success' do it 'is_hashs arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_integer_spec.rb b/spec/acceptance/is_integer_spec.rb index bf6902b..7333687 100755 --- a/spec/acceptance/is_integer_spec.rb +++ b/spec/acceptance/is_integer_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_integer function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_integer function' do describe 'success' do it 'is_integers arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_ip_address_spec.rb b/spec/acceptance/is_ip_address_spec.rb index ed7a854..2c62c77 100755 --- a/spec/acceptance/is_ip_address_spec.rb +++ b/spec/acceptance/is_ip_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_ip_address function' do describe 'success' do it 'is_ip_addresss ipv4' do pp = <<-EOS diff --git a/spec/acceptance/is_ipv4_address_spec.rb b/spec/acceptance/is_ipv4_address_spec.rb index 5dc6bf5..abe26d8 100755 --- a/spec/acceptance/is_ipv4_address_spec.rb +++ b/spec/acceptance/is_ipv4_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_ipv4_address function' do describe 'success' do it 'is_ipv4_addresss' do pp = <<-EOS diff --git a/spec/acceptance/is_ipv6_address_spec.rb b/spec/acceptance/is_ipv6_address_spec.rb index 1e88be8..73a3fa4 100755 --- a/spec/acceptance/is_ipv6_address_spec.rb +++ b/spec/acceptance/is_ipv6_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_ipv6_address function' do describe 'success' do it 'is_ipv6_addresss' do pp = <<-EOS diff --git a/spec/acceptance/is_mac_address_spec.rb b/spec/acceptance/is_mac_address_spec.rb index a2c892f..617bef6 100755 --- a/spec/acceptance/is_mac_address_spec.rb +++ b/spec/acceptance/is_mac_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_mac_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_mac_address function' do describe 'success' do it 'is_mac_addresss a mac' do pp = <<-EOS diff --git a/spec/acceptance/is_numeric_spec.rb b/spec/acceptance/is_numeric_spec.rb index 21c8988..7e65384 100755 --- a/spec/acceptance/is_numeric_spec.rb +++ b/spec/acceptance/is_numeric_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_numeric function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_numeric function' do describe 'success' do it 'is_numerics arrays' do pp = <<-EOS diff --git a/spec/acceptance/is_string_spec.rb b/spec/acceptance/is_string_spec.rb index f526888..bee5e01 100755 --- a/spec/acceptance/is_string_spec.rb +++ b/spec/acceptance/is_string_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'is_string function' do describe 'success' do it 'is_strings arrays' do pp = <<-EOS diff --git a/spec/acceptance/join_keys_to_values_spec.rb b/spec/acceptance/join_keys_to_values_spec.rb index 70493fd..ae6947e 100755 --- a/spec/acceptance/join_keys_to_values_spec.rb +++ b/spec/acceptance/join_keys_to_values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'join_keys_to_values function' do describe 'success' do it 'join_keys_to_valuess hashes' do pp = <<-EOS diff --git a/spec/acceptance/join_spec.rb b/spec/acceptance/join_spec.rb index 5397ce2..75b88d8 100755 --- a/spec/acceptance/join_spec.rb +++ b/spec/acceptance/join_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'join function' do describe 'success' do it 'joins arrays' do pp = <<-EOS diff --git a/spec/acceptance/keys_spec.rb b/spec/acceptance/keys_spec.rb index 176918e..65bfe28 100755 --- a/spec/acceptance/keys_spec.rb +++ b/spec/acceptance/keys_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'keys function' do describe 'success' do it 'keyss hashes' do pp = <<-EOS diff --git a/spec/acceptance/loadjson_spec.rb b/spec/acceptance/loadjson_spec.rb index 2992c37..ebd5307 100644 --- a/spec/acceptance/loadjson_spec.rb +++ b/spec/acceptance/loadjson_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_acceptance' tmpdir = default.tmpdir('stdlib') -describe 'loadjson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'loadjson function' do describe 'success' do it 'loadjsons array of values' do shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/testjson.json") diff --git a/spec/acceptance/loadyaml_spec.rb b/spec/acceptance/loadyaml_spec.rb index ba3f0b7..57fb8cb 100644 --- a/spec/acceptance/loadyaml_spec.rb +++ b/spec/acceptance/loadyaml_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper_acceptance' tmpdir = default.tmpdir('stdlib') -describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'loadyaml function' do describe 'success' do it 'loadyamls array of values' do shell("echo '--- diff --git a/spec/acceptance/lstrip_spec.rb b/spec/acceptance/lstrip_spec.rb index 3dc952f..eba5d0d 100755 --- a/spec/acceptance/lstrip_spec.rb +++ b/spec/acceptance/lstrip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'lstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'lstrip function' do describe 'success' do it 'lstrips arrays' do pp = <<-EOS diff --git a/spec/acceptance/max_spec.rb b/spec/acceptance/max_spec.rb index f04e3d2..3caa813 100755 --- a/spec/acceptance/max_spec.rb +++ b/spec/acceptance/max_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'max function' do describe 'success' do it 'maxs arrays' do pp = <<-EOS diff --git a/spec/acceptance/member_spec.rb b/spec/acceptance/member_spec.rb index fe75a07..2bcadd3 100755 --- a/spec/acceptance/member_spec.rb +++ b/spec/acceptance/member_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'member function' do shared_examples 'item found' do it 'should output correctly' do apply_manifest(pp, :catch_failures => true) do |r| diff --git a/spec/acceptance/merge_spec.rb b/spec/acceptance/merge_spec.rb index 227b994..814db4e 100755 --- a/spec/acceptance/merge_spec.rb +++ b/spec/acceptance/merge_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'merge function' do describe 'success' do it 'should merge two hashes' do pp = <<-EOS diff --git a/spec/acceptance/min_spec.rb b/spec/acceptance/min_spec.rb index 509092d..7b18fac 100755 --- a/spec/acceptance/min_spec.rb +++ b/spec/acceptance/min_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'min function' do describe 'success' do it 'mins arrays' do pp = <<-EOS diff --git a/spec/acceptance/num2bool_spec.rb b/spec/acceptance/num2bool_spec.rb index 1d99ba0..00d0ddc 100755 --- a/spec/acceptance/num2bool_spec.rb +++ b/spec/acceptance/num2bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'num2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'num2bool function' do describe 'success' do it 'bools positive numbers and numeric strings as true' do pp = <<-EOS diff --git a/spec/acceptance/parsejson_spec.rb b/spec/acceptance/parsejson_spec.rb index d0e3de8..52133e4 100755 --- a/spec/acceptance/parsejson_spec.rb +++ b/spec/acceptance/parsejson_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'parsejson function' do describe 'success' do it 'parses valid json' do pp = <<-EOS diff --git a/spec/acceptance/parseyaml_spec.rb b/spec/acceptance/parseyaml_spec.rb index 64511f1..acbda46 100755 --- a/spec/acceptance/parseyaml_spec.rb +++ b/spec/acceptance/parseyaml_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'parseyaml function' do describe 'success' do it 'parses valid yaml' do pp = <<-EOS diff --git a/spec/acceptance/pick_default_spec.rb b/spec/acceptance/pick_default_spec.rb index a663f54..e7e25ab 100755 --- a/spec/acceptance/pick_default_spec.rb +++ b/spec/acceptance/pick_default_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'pick_default function' do describe 'success' do it 'pick_defaults a default value' do pp = <<-EOS diff --git a/spec/acceptance/pick_spec.rb b/spec/acceptance/pick_spec.rb index 46cf63f..c70b2d9 100755 --- a/spec/acceptance/pick_spec.rb +++ b/spec/acceptance/pick_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'pick function' do describe 'success' do it 'picks a default value' do pp = <<-EOS diff --git a/spec/acceptance/prefix_spec.rb b/spec/acceptance/prefix_spec.rb index de55530..58c691d 100755 --- a/spec/acceptance/prefix_spec.rb +++ b/spec/acceptance/prefix_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'prefix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'prefix function' do describe 'success' do it 'prefixes array of values' do pp = <<-EOS diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb index cd4cb87..829d087 100644 --- a/spec/acceptance/pw_hash_spec.rb +++ b/spec/acceptance/pw_hash_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper_acceptance' # Windows and OS X do not have useful implementations of crypt(3) -describe 'pw_hash function', :unless => (UNSUPPORTED_PLATFORMS + ['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do +describe 'pw_hash function', :unless => (['windows', 'Darwin', 'SLES']).include?(fact('operatingsystem')) do describe 'success' do it 'hashes passwords' do pp = <<-EOS diff --git a/spec/acceptance/range_spec.rb b/spec/acceptance/range_spec.rb index a3ccd33..f57f884 100755 --- a/spec/acceptance/range_spec.rb +++ b/spec/acceptance/range_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'range function' do describe 'success' do it 'ranges letters' do pp = <<-EOS diff --git a/spec/acceptance/reject_spec.rb b/spec/acceptance/reject_spec.rb index 7f16a00..ce4342d 100755 --- a/spec/acceptance/reject_spec.rb +++ b/spec/acceptance/reject_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'reject function' do describe 'success' do it 'rejects array of values' do pp = <<-EOS diff --git a/spec/acceptance/reverse_spec.rb b/spec/acceptance/reverse_spec.rb index c3f0156..3b5dfad 100755 --- a/spec/acceptance/reverse_spec.rb +++ b/spec/acceptance/reverse_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'reverse function' do describe 'success' do it 'reverses strings' do pp = <<-EOS diff --git a/spec/acceptance/rstrip_spec.rb b/spec/acceptance/rstrip_spec.rb index b57a8b0..150dac1 100755 --- a/spec/acceptance/rstrip_spec.rb +++ b/spec/acceptance/rstrip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'rstrip function' do describe 'success' do it 'rstrips arrays' do pp = <<-EOS diff --git a/spec/acceptance/shuffle_spec.rb b/spec/acceptance/shuffle_spec.rb index b840d1f..0738383 100755 --- a/spec/acceptance/shuffle_spec.rb +++ b/spec/acceptance/shuffle_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'shuffle function' do describe 'success' do it 'shuffles arrays' do pp = <<-EOS diff --git a/spec/acceptance/size_spec.rb b/spec/acceptance/size_spec.rb index a52b778..6390c20 100755 --- a/spec/acceptance/size_spec.rb +++ b/spec/acceptance/size_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'size function' do describe 'success' do it 'single string size' do pp = <<-EOS diff --git a/spec/acceptance/sort_spec.rb b/spec/acceptance/sort_spec.rb index c85bfab..e7ff7f7 100755 --- a/spec/acceptance/sort_spec.rb +++ b/spec/acceptance/sort_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'sort function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'sort function' do describe 'success' do it 'sorts arrays' do pp = <<-EOS diff --git a/spec/acceptance/squeeze_spec.rb b/spec/acceptance/squeeze_spec.rb index 400a458..3324691 100755 --- a/spec/acceptance/squeeze_spec.rb +++ b/spec/acceptance/squeeze_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'squeeze function' do describe 'success' do it 'squeezes arrays' do pp = <<-EOS diff --git a/spec/acceptance/str2bool_spec.rb b/spec/acceptance/str2bool_spec.rb index cf549da..9a8c06c 100755 --- a/spec/acceptance/str2bool_spec.rb +++ b/spec/acceptance/str2bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'str2bool function' do describe 'success' do it 'works with "y"' do pp = <<-EOS diff --git a/spec/acceptance/str2saltedsha512_spec.rb b/spec/acceptance/str2saltedsha512_spec.rb index 993e63b..5f03924 100755 --- a/spec/acceptance/str2saltedsha512_spec.rb +++ b/spec/acceptance/str2saltedsha512_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'str2saltedsha512 function' do describe 'success' do it 'works with "y"' do pp = <<-EOS diff --git a/spec/acceptance/strftime_spec.rb b/spec/acceptance/strftime_spec.rb index 53b7f90..38521b0 100755 --- a/spec/acceptance/strftime_spec.rb +++ b/spec/acceptance/strftime_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'strftime function' do describe 'success' do it 'gives the Century' do pp = <<-EOS diff --git a/spec/acceptance/strip_spec.rb b/spec/acceptance/strip_spec.rb index 906fd7a..05cd395 100755 --- a/spec/acceptance/strip_spec.rb +++ b/spec/acceptance/strip_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'strip function' do describe 'success' do it 'strips arrays' do pp = <<-EOS diff --git a/spec/acceptance/suffix_spec.rb b/spec/acceptance/suffix_spec.rb index 630f866..60a6264 100755 --- a/spec/acceptance/suffix_spec.rb +++ b/spec/acceptance/suffix_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'suffix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'suffix function' do describe 'success' do it 'suffixes array of values' do pp = <<-EOS diff --git a/spec/acceptance/swapcase_spec.rb b/spec/acceptance/swapcase_spec.rb index b7894fb..9f94c0d 100755 --- a/spec/acceptance/swapcase_spec.rb +++ b/spec/acceptance/swapcase_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'swapcase function' do describe 'success' do it 'works with strings' do pp = <<-EOS diff --git a/spec/acceptance/time_spec.rb b/spec/acceptance/time_spec.rb index cdb2960..dae1166 100755 --- a/spec/acceptance/time_spec.rb +++ b/spec/acceptance/time_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'time function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'time function' do describe 'success' do it 'gives the time' do pp = <<-EOS diff --git a/spec/acceptance/to_bytes_spec.rb b/spec/acceptance/to_bytes_spec.rb index 2b4c61f..b1015a3 100755 --- a/spec/acceptance/to_bytes_spec.rb +++ b/spec/acceptance/to_bytes_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'to_bytes function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'to_bytes function' do describe 'success' do it 'converts kB to B' do pp = <<-EOS diff --git a/spec/acceptance/try_get_value_spec.rb b/spec/acceptance/try_get_value_spec.rb index c0bf38a..716241c 100755 --- a/spec/acceptance/try_get_value_spec.rb +++ b/spec/acceptance/try_get_value_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'try_get_value function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'try_get_value function' do describe 'success' do it 'gets a value' do pp = <<-EOS diff --git a/spec/acceptance/type_spec.rb b/spec/acceptance/type_spec.rb index 67e3248..5cc9470 100755 --- a/spec/acceptance/type_spec.rb +++ b/spec/acceptance/type_spec.rb @@ -1,29 +1,29 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'type function', :unless => (UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) || is_future_parser_enabled?) do +describe 'type function' do describe 'success' do it 'types arrays' do pp = <<-EOS $a = ["the","public","art","galleries"] # Anagram: Large picture halls, I bet $o = type($a) - notice(inline_template('type is <%= @o.inspect %>')) + notice(inline_template('type is <%= @o.to_s %>')) EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is "array"/) + expect(r.stdout).to match(/type is Tuple\[String.*, String.*, String.*, String.*\]/) end end it 'types strings' do pp = <<-EOS $a = "blowzy night-frumps vex'd jack q" $o = type($a) - notice(inline_template('type is <%= @o.inspect %>')) + notice(inline_template('type is <%= @o.to_s %>')) EOS apply_manifest(pp, :catch_failures => true) do |r| - expect(r.stdout).to match(/type is "string"/) + expect(r.stdout).to match(/type is String/) end end it 'types hashes' diff --git a/spec/acceptance/union_spec.rb b/spec/acceptance/union_spec.rb index 160fd7b..7229bf5 100755 --- a/spec/acceptance/union_spec.rb +++ b/spec/acceptance/union_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'union function' do describe 'success' do it 'unions arrays' do pp = <<-EOS diff --git a/spec/acceptance/unique_spec.rb b/spec/acceptance/unique_spec.rb index bfadad1..7fb5eca 100755 --- a/spec/acceptance/unique_spec.rb +++ b/spec/acceptance/unique_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'unique function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'unique function' do describe 'success' do it 'uniques arrays' do pp = <<-EOS diff --git a/spec/acceptance/unsupported_spec.rb b/spec/acceptance/unsupported_spec.rb deleted file mode 100755 index 1c559f6..0000000 --- a/spec/acceptance/unsupported_spec.rb +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env ruby -S rspec -require 'spec_helper_acceptance' - -describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do - it 'should fail' do - pp = <<-EOS - class { 'mysql::server': } - EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i) - end -end diff --git a/spec/acceptance/upcase_spec.rb b/spec/acceptance/upcase_spec.rb index 3d2906d..1782309 100755 --- a/spec/acceptance/upcase_spec.rb +++ b/spec/acceptance/upcase_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'upcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'upcase function' do describe 'success' do it 'upcases arrays' do pp = <<-EOS diff --git a/spec/acceptance/uriescape_spec.rb b/spec/acceptance/uriescape_spec.rb index 7e30205..e123425 100755 --- a/spec/acceptance/uriescape_spec.rb +++ b/spec/acceptance/uriescape_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'uriescape function' do describe 'success' do it 'uriescape strings' do pp = <<-EOS diff --git a/spec/acceptance/validate_absolute_path_spec.rb b/spec/acceptance/validate_absolute_path_spec.rb index 7082e84..880850d 100755 --- a/spec/acceptance/validate_absolute_path_spec.rb +++ b/spec/acceptance/validate_absolute_path_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_absolute_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_absolute_path function' do describe 'success' do %w{ C:/ diff --git a/spec/acceptance/validate_array_spec.rb b/spec/acceptance/validate_array_spec.rb index 2f549d5..a76321d 100755 --- a/spec/acceptance/validate_array_spec.rb +++ b/spec/acceptance/validate_array_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_array function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_augeas_spec.rb b/spec/acceptance/validate_augeas_spec.rb index 71a4c84..be213d3 100755 --- a/spec/acceptance/validate_augeas_spec.rb +++ b/spec/acceptance/validate_augeas_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_augeas function', :unless => ((UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem'))) or (fact('osfamily') == 'windows')) do +describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do describe 'prep' do it 'installs augeas for tests' end diff --git a/spec/acceptance/validate_bool_spec.rb b/spec/acceptance/validate_bool_spec.rb index 5c52d0f..993f9ef 100755 --- a/spec/acceptance/validate_bool_spec.rb +++ b/spec/acceptance/validate_bool_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_bool function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_cmd_spec.rb b/spec/acceptance/validate_cmd_spec.rb index 5ac66fd..5fc7b94 100755 --- a/spec/acceptance/validate_cmd_spec.rb +++ b/spec/acceptance/validate_cmd_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_cmd function' do describe 'success' do it 'validates a true command' do pp = <<-EOS diff --git a/spec/acceptance/validate_hash_spec.rb b/spec/acceptance/validate_hash_spec.rb index 637df0a..fc0f079 100755 --- a/spec/acceptance/validate_hash_spec.rb +++ b/spec/acceptance/validate_hash_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_hash function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_ipv4_address_spec.rb b/spec/acceptance/validate_ipv4_address_spec.rb index 64841c3..67d3139 100755 --- a/spec/acceptance/validate_ipv4_address_spec.rb +++ b/spec/acceptance/validate_ipv4_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_ipv4_address function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_ipv6_address_spec.rb b/spec/acceptance/validate_ipv6_address_spec.rb index 6426d1a..eaa845d 100755 --- a/spec/acceptance/validate_ipv6_address_spec.rb +++ b/spec/acceptance/validate_ipv6_address_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_ipv6_address function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/validate_re_spec.rb b/spec/acceptance/validate_re_spec.rb index 22f6d47..eefb286 100755 --- a/spec/acceptance/validate_re_spec.rb +++ b/spec/acceptance/validate_re_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_re function' do describe 'success' do it 'validates a string' do pp = <<-EOS diff --git a/spec/acceptance/validate_slength_spec.rb b/spec/acceptance/validate_slength_spec.rb index 1ab2bb9..c29fd23 100755 --- a/spec/acceptance/validate_slength_spec.rb +++ b/spec/acceptance/validate_slength_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_slength function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_slength function' do describe 'success' do it 'validates a single string max' do pp = <<-EOS diff --git a/spec/acceptance/validate_string_spec.rb b/spec/acceptance/validate_string_spec.rb index ae3468f..f04608d 100755 --- a/spec/acceptance/validate_string_spec.rb +++ b/spec/acceptance/validate_string_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'validate_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'validate_string function' do describe 'success' do it 'validates a single argument' do pp = <<-EOS diff --git a/spec/acceptance/values_at_spec.rb b/spec/acceptance/values_at_spec.rb index da63cf3..eb0bf4f 100755 --- a/spec/acceptance/values_at_spec.rb +++ b/spec/acceptance/values_at_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'values_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'values_at function' do describe 'success' do it 'returns a specific value' do pp = <<-EOS diff --git a/spec/acceptance/values_spec.rb b/spec/acceptance/values_spec.rb index a2eff32..cef1c9d 100755 --- a/spec/acceptance/values_spec.rb +++ b/spec/acceptance/values_spec.rb @@ -1,7 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'values function' do describe 'success' do it 'returns an array of values' do pp = <<-EOS @@ -13,12 +13,7 @@ describe 'values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper $output = values($arg) notice(inline_template('<%= @output.sort.inspect %>')) EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "2", "3"\]/) - end - + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 2, 3\]/) end end describe 'failure' do diff --git a/spec/acceptance/zip_spec.rb b/spec/acceptance/zip_spec.rb index 139079e..ae22896 100755 --- a/spec/acceptance/zip_spec.rb +++ b/spec/acceptance/zip_spec.rb @@ -1,8 +1,7 @@ #! /usr/bin/env ruby -S rspec require 'spec_helper_acceptance' -require 'puppet' -describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do +describe 'zip function' do describe 'success' do it 'zips two arrays of numbers together' do pp = <<-EOS @@ -11,11 +10,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\], \["3", "7"\], \["4", "8"\]\]/) - end + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]/) end it 'zips two arrays of numbers & bools together' do pp = <<-EOS @@ -24,11 +19,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", true\], \["2", true\], \["three", false\], \["4", false\]\]/) - end + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]/) end it 'zips two arrays of numbers together and flattens them' do # XXX This only tests the argument `true`, even though the following are valid: @@ -41,11 +32,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two,true) notice(inline_template('<%= @output.inspect %>')) EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\["1", "5", "2", "6", "3", "7", "4", "8"\]/) - end + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[1, 5, 2, 6, 3, 7, 4, 8\]/) end it 'handles unmatched length' do # XXX Is this expected behavior? @@ -55,11 +42,7 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - if is_future_parser_enabled? - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/) - else - expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\["1", "5"\], \["2", "6"\]\]/) - end + expect(apply_manifest(pp, :catch_failures => true).stdout).to match(/\[\[1, 5\], \[2, 6\]\]/) end end describe 'failure' do @@ -69,7 +52,6 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one) notice(inline_template('<%= @output.inspect %>')) EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Wrong number of arguments/) end it 'handles improper argument types' do @@ -79,7 +61,6 @@ describe 'zip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operati $output = zip($one,$two) notice(inline_template('<%= @output.inspect %>')) EOS - expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/Requires array/) end end diff --git a/spec/aliases/absolute_path_spec.rb b/spec/aliases/absolute_path_spec.rb index 3fb9d12..eeda76a 100644 --- a/spec/aliases/absolute_path_spec.rb +++ b/spec/aliases/absolute_path_spec.rb @@ -15,6 +15,8 @@ if Puppet.version.to_f >= 4.5 / /var/tmp /var/opt/../lib/puppet + /var/ůťƒ8 + /var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -50,6 +52,8 @@ if Puppet.version.to_f >= 4.5 etc/puppetlabs/puppet opt/puppet/bin relative\\windows + \var\ůťƒ8 + \var\ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/httpsurl_spec.rb b/spec/aliases/httpsurl_spec.rb index 97ae006..9cc9a76 100644 --- a/spec/aliases/httpsurl_spec.rb +++ b/spec/aliases/httpsurl_spec.rb @@ -7,6 +7,8 @@ if Puppet.version.to_f >= 4.5 https://hello.com https://notcreative.org https://notexciting.co.uk + https://graphemica.com/❤ + https://graphemica.com/緩 }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -26,7 +28,9 @@ if Puppet.version.to_f >= 4.5 '', "httds://notquiteright.org", "hptts:/nah", - "https;//notrightbutclose.org" + "https;//notrightbutclose.org", + "http://graphemica.com/❤", + "http://graphemica.com/緩" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/httpurl_spec.rb b/spec/aliases/httpurl_spec.rb index 8bd57ca..f92ddb3 100644 --- a/spec/aliases/httpurl_spec.rb +++ b/spec/aliases/httpurl_spec.rb @@ -10,6 +10,8 @@ if Puppet.version.to_f >= 4.5 http://anhttp.com http://runningoutofideas.gov http:// + http://graphemica.com/❤ + http://graphemica.com/緩 }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -29,7 +31,9 @@ if Puppet.version.to_f >= 4.5 '', "httds://notquiteright.org", "hptts:/nah", - "https;//notrightbutclose.org" + "https;//notrightbutclose.org", + "hts://graphemica.com/❤", + "https:graphemica.com/緩" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/ipv6_spec.rb b/spec/aliases/ipv6_spec.rb index 13d7c3e..6237eba 100644 --- a/spec/aliases/ipv6_spec.rb +++ b/spec/aliases/ipv6_spec.rb @@ -5,7 +5,14 @@ if Puppet.version.to_f >= 4.5 describe 'accepts ipv6 addresses' do [ '2001:0db8:85a3:0000:0000:8a2e:0370:7334', - 'fa76:8765:34ac:0823:ab76:eee9:0987:1111' + 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', + 'fe80:0000:0000:0000:0204:61ff:fe9d:f156', + 'fe80:0:0:0:204:61ff:fe9d:f156', + 'fe80::204:61ff:fe9d:f156', + 'fe80:0:0:0:0204:61ff:254.157.241.86', + '::1', + 'fe80::', + '2001::', ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -18,7 +25,10 @@ if Puppet.version.to_f >= 4.5 'nope', '77', '4.4.4', - '2000:7334' + '2000:7334', + '::ffff:2.3.4', + '::ffff:257.1.2.3', + '::ffff:12345678901234567890.1.26', ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/unixpath_spec.rb b/spec/aliases/unixpath_spec.rb index aee161d..7824cb6 100644 --- a/spec/aliases/unixpath_spec.rb +++ b/spec/aliases/unixpath_spec.rb @@ -7,6 +7,8 @@ if Puppet.version.to_f >= 4.5 /usr2/username/bin:/usr/local/bin:/usr/bin:. /var/tmp /Users/helencampbell/workspace/puppetlabs-stdlib + /var/ůťƒ8 + /var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -27,7 +29,9 @@ if Puppet.version.to_f >= 4.5 "C:/whatever", "\\var\\tmp", "\\Users/hc/wksp/stdlib", - "*/Users//nope" + "*/Users//nope", + "var\ůťƒ8", + "var\ネット" ].each do |value| describe value.inspect do let(:params) {{ value: value }} diff --git a/spec/aliases/windowspath_spec.rb b/spec/aliases/windowspath_spec.rb index c13794e..b8ddcb7 100644 --- a/spec/aliases/windowspath_spec.rb +++ b/spec/aliases/windowspath_spec.rb @@ -10,6 +10,8 @@ if Puppet.version.to_f >= 4.5 X:/foo/bar X:\\foo\\bar \\\\host\\windows + X:/var/ůťƒ8 + X:/var/ネット }.each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -30,7 +32,9 @@ if Puppet.version.to_f >= 4.5 "httds://notquiteright.org", "/usr2/username/bin:/usr/local/bin:/usr/bin:.", "C;//notright/here", - "C:noslashes" + "C:noslashes", + "C:ネット", + "C:ůťƒ8" ].each do |value| describe value.inspect do let(:params) {{ value: value }} @@ -38,7 +42,6 @@ if Puppet.version.to_f >= 4.5 end end end - end end end diff --git a/spec/functions/any2array_spec.rb b/spec/functions/any2array_spec.rb index 70121f1..631657f 100755 --- a/spec/functions/any2array_spec.rb +++ b/spec/functions/any2array_spec.rb @@ -12,4 +12,10 @@ describe "any2array" do it { is_expected.to run.with_params({}).and_return([]) } it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } it { is_expected.to run.with_params({ 'key' => 'value' }).and_return(['key', 'value']) } + + 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(['Ü']) } + it { is_expected.to run.with_params('∇').and_return(['∇']) } + it { is_expected.to run.with_params('€', '万', 'Ö', '♥', '割').and_return(['€', '万', 'Ö', '♥', '割']) } end diff --git a/spec/functions/basename_spec.rb b/spec/functions/basename_spec.rb index c84e192..3e02b01 100755 --- a/spec/functions/basename_spec.rb +++ b/spec/functions/basename_spec.rb @@ -11,4 +11,9 @@ describe 'basename' do it { is_expected.to run.with_params('/path/to/a/file.ext', '.ext').and_return('file') } 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 + it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('竹.ext') } + it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ', '.ㄘ').and_return('竹') } + end end diff --git a/spec/functions/chomp_spec.rb b/spec/functions/chomp_spec.rb index 6878742..56bd9b1 100755 --- a/spec/functions/chomp_spec.rb +++ b/spec/functions/chomp_spec.rb @@ -17,4 +17,9 @@ describe 'chomp' do it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") } 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(["one", "two", "three"]) } + + context 'should run 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 end diff --git a/spec/functions/chop_spec.rb b/spec/functions/chop_spec.rb index db7d18b..b70fc37 100755 --- a/spec/functions/chop_spec.rb +++ b/spec/functions/chop_spec.rb @@ -17,4 +17,9 @@ describe 'chop' do it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return("one") } 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(["one", "tw", "three"]) } + + context 'should run 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 end diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index eb76233..6ab1b6e 100755 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -11,7 +11,11 @@ describe 'concat' do it { is_expected.to run.with_params(['1','2','3'],[['4','5'],'6']).and_return(['1','2','3',['4','5'],'6']) } it { is_expected.to run.with_params(['1','2'],['3','4'],['5','6']).and_return(['1','2','3','4','5','6']) } it { is_expected.to run.with_params(['1','2'],'3','4',['5','6']).and_return(['1','2','3','4','5','6']) } + +context 'should run 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(['ấ','β','©'],['đ','ể','文字列']).and_return(['ấ','β','©','đ','ể','文字列']) } +end it "should leave the original array intact" do argument1 = ['1','2','3'] diff --git a/spec/functions/count_spec.rb b/spec/functions/count_spec.rb index c8d1960..3854cb8 100755 --- a/spec/functions/count_spec.rb +++ b/spec/functions/count_spec.rb @@ -15,4 +15,9 @@ describe 'count' do it { is_expected.to run.with_params(["one", nil, "two"]).and_return(2) } it { is_expected.to run.with_params(["one", "", "two"]).and_return(2) } it { is_expected.to run.with_params(["one", :undef, "two"]).and_return(2) } + + it { is_expected.to run.with_params(["ổņ℮", "ŧщộ", "three"]).and_return(3) } + it { is_expected.to run.with_params(["ổņ℮", "ŧщộ", "ŧщộ"], "ŧщộ").and_return(2) } + it { is_expected.to run.with_params(["ổņ℮", nil, "ŧщộ"]).and_return(2) } + it { is_expected.to run.with_params(["ổņ℮", :undef, "ŧщộ"]).and_return(2) } end diff --git a/spec/functions/deep_merge_spec.rb b/spec/functions/deep_merge_spec.rb index 397e048..c91a07e 100755 --- a/spec/functions/deep_merge_spec.rb +++ b/spec/functions/deep_merge_spec.rb @@ -52,4 +52,8 @@ describe 'deep_merge' do expect(argument1).to eq(original1) expect(argument2).to eq(original2) end + + context 'should run 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 e2f3abe..a0db0b7 100755 --- a/spec/functions/defined_with_params_spec.rb +++ b/spec/functions/defined_with_params_spec.rb @@ -11,6 +11,11 @@ describe 'defined_with_params' do it { is_expected.to run.with_params('User[dan]', {}).and_return(true) } 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 + it { is_expected.to run.with_params('User[ĵĭмოү]', {}).and_return(false) } + it { is_expected.to run.with_params('User[ポーラ]', {}).and_return(false) } + end end describe 'when compared against a resource with attributes' do diff --git a/spec/functions/delete_at_spec.rb b/spec/functions/delete_at_spec.rb index 0e19472..0471039 100755 --- a/spec/functions/delete_at_spec.rb +++ b/spec/functions/delete_at_spec.rb @@ -18,6 +18,8 @@ describe 'delete_at' do it { is_expected.to run.with_params([0, 1, 2], 1).and_return([0, 2]) } it { is_expected.to run.with_params([0, 1, 2], -1).and_return([0, 1]) } it { is_expected.to run.with_params([0, 1, 2], -4).and_return([0, 1, 2]) } + it { is_expected.to run.with_params(["ƒờở", "βāř", "ьầż"], 1).and_return(["ƒờở", "ьầż"]) } + it "should leave the original array intact" do argument = [1, 2, 3] diff --git a/spec/functions/delete_spec.rb b/spec/functions/delete_spec.rb index b44accf..4e37865 100755 --- a/spec/functions/delete_spec.rb +++ b/spec/functions/delete_spec.rb @@ -19,6 +19,7 @@ describe 'delete' do it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } it { is_expected.to run.with_params(['two', 'one', 'two', 'three', 'two'], 'two').and_return(['one', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three', 'two'], ['one', 'two']).and_return(['three']) } + it { is_expected.to run.with_params(['ồאּẻ', 'ŧẅơ', 'ŧңŗё℮', 'ŧẅơ'], ['ồאּẻ', 'ŧẅơ']).and_return(['ŧңŗё℮']) } end describe 'deleting from a string' do @@ -30,7 +31,8 @@ describe 'delete' do it { is_expected.to run.with_params('barfoobar', 'bar').and_return('foo') } it { is_expected.to run.with_params('foobarbabarz', 'bar').and_return('foobaz') } it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') } - # this is so sick + it { is_expected.to run.with_params('ƒōōβậяβậβậяź', ['ƒōō', 'βậя']).and_return('βậź') } + it { is_expected.to run.with_params('barfoobar', ['barbar', 'foo']).and_return('barbar') } it { is_expected.to run.with_params('barfoobar', ['foo', 'barbar']).and_return('') } end @@ -47,6 +49,10 @@ describe 'delete' do .with_params({'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3'}, ['key1', 'key2']) \ .and_return( {'key3' => 'value3'}) } + it { is_expected.to run \ + .with_params({'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3'}, ['ĸəұ1', 'ĸəұ2']) \ + .and_return( {'ĸəұ3' => 'νãŀủĕ3'}) + } end it "should leave the original array intact" do diff --git a/spec/functions/delete_undef_values_spec.rb b/spec/functions/delete_undef_values_spec.rb index ec9fb9c..c20cee2 100755 --- a/spec/functions/delete_undef_values_spec.rb +++ b/spec/functions/delete_undef_values_spec.rb @@ -16,6 +16,7 @@ describe 'delete_undef_values' do end it { is_expected.to run.with_params([undef_value]).and_return([]) } it { is_expected.to run.with_params(['one',undef_value,'two','three']).and_return(['one','two','three']) } + it { is_expected.to run.with_params(['ớņέ',undef_value,'ŧשּׁō','ŧħґëə']).and_return(['ớņέ','ŧשּׁō','ŧħґëə']) } end it "should leave the original argument intact" do diff --git a/spec/functions/delete_values_spec.rb b/spec/functions/delete_values_spec.rb index 12907d4..329fa0b 100755 --- a/spec/functions/delete_values_spec.rb +++ b/spec/functions/delete_values_spec.rb @@ -19,7 +19,11 @@ describe 'delete_values' do .and_return({'key1' => 'value1'}) } it { is_expected.to run \ - .with_params({'key1' => 'value1', 'key2' => 'value to delete'}, 'value to delete') \ + .with_params({'ҝếỵ1 ' => 'νâĺūẹ1', 'ҝếỵ2' => 'value to delete'}, 'value to delete') \ + .and_return({'ҝếỵ1 ' => 'νâĺūẹ1'}) + } + it { is_expected.to run \ + .with_params({'key1' => 'value1', 'key2' => 'νǎŀữ℮ ťớ đêłểťė'}, 'νǎŀữ℮ ťớ đêłểťė') \ .and_return({'key1' => 'value1'}) } it { is_expected.to run \ diff --git a/spec/functions/deprecation_spec.rb b/spec/functions/deprecation_spec.rb index cee4f1c..8a65b69 100644 --- a/spec/functions/deprecation_spec.rb +++ b/spec/functions/deprecation_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.0 +if Puppet.version.to_f >= 4.5 describe 'deprecation' do before(:each) { # this is to reset the strict variable to default @@ -40,7 +40,7 @@ if Puppet.version.to_f >= 4.0 Puppet.settings[:strict] = :warning } end -else +elsif Puppet.version.to_f < 4.0 # Puppet version < 4 will use these tests. describe 'deprecation' do after(:all) do diff --git a/spec/functions/difference_spec.rb b/spec/functions/difference_spec.rb index d5e983d..0ae3689 100755 --- a/spec/functions/difference_spec.rb +++ b/spec/functions/difference_spec.rb @@ -12,8 +12,10 @@ describe 'difference' do it { is_expected.to run.with_params([], []).and_return([]) } it { is_expected.to run.with_params([], ['one']).and_return([]) } it { is_expected.to run.with_params(['one'], ['one']).and_return([]) } + it { is_expected.to run.with_params(['ớņέ'], ['']).and_return(['ớņέ']) } it { is_expected.to run.with_params(['one'], []).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one']) } + it { is_expected.to run.with_params(['ớņέ', 'ŧשּׁō', 'ŧħґëə', 2], ['ŧשּׁō', 'ŧħґëə']).and_return(['ớņέ', 2]) } it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['one']) } diff --git a/spec/functions/dig44_spec.rb b/spec/functions/dig44_spec.rb index 4f7408d..a7b8a3d 100644 --- a/spec/functions/dig44_spec.rb +++ b/spec/functions/dig44_spec.rb @@ -25,6 +25,18 @@ describe 'dig44' do } end + let(:utf8_data) do + { + 'ẵ' => { + 'в' => [ + '©', + 'ĝ', + 'に', + ] + } + } + end + context 'single values' do it 'should exist' do is_expected.not_to be_nil @@ -100,6 +112,20 @@ describe 'dig44' do it 'should return "nil" if value is not found and no default value is provided' do is_expected.to run.with_params(data, %w(a 1)).and_return(nil) end + end + + context 'Internationalization (i18N) values' do + + it 'should be able to return a unicode character' do + is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 0]).and_return('©') + end + it 'should be able to return a utf8 character' do + is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 1]).and_return('ĝ') + end + + it 'should be able to return a double byte character' do + is_expected.to run.with_params(utf8_data, ['ẵ', 'в', 2]).and_return('に') + end end end diff --git a/spec/functions/dirname_spec.rb b/spec/functions/dirname_spec.rb index 46c4c35..c494915 100755 --- a/spec/functions/dirname_spec.rb +++ b/spec/functions/dirname_spec.rb @@ -10,4 +10,9 @@ describe 'dirname' do it { is_expected.to run.with_params('/path/to/a/file.ext', []).and_raise_error(Puppet::ParseError) } 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 + it { is_expected.to run.with_params('scheme:///√ạĺűē/竹.ext').and_return('scheme:///√ạĺűē') } + it { is_expected.to run.with_params('ҝẽγ:/√ạĺűē/竹.ㄘ').and_return('ҝẽγ:/√ạĺűē') } + end end diff --git a/spec/functions/dos2unix_spec.rb b/spec/functions/dos2unix_spec.rb index 9c84703..97abae7 100644 --- a/spec/functions/dos2unix_spec.rb +++ b/spec/functions/dos2unix_spec.rb @@ -29,12 +29,19 @@ describe 'dos2unix' do end end - context 'Converting from unix to unix format' do - sample_text = "Hello\nWorld\n" - desired_output = "Hello\nWorld\n" + context 'Internationalization (i18N) values' do + sample_text_utf8 = "Ħ℮ļłǿ\r\nשׁөŕłđ\r\n" + desired_output_utf8 = "Ħ℮ļłǿ\nשׁөŕłđ\n" - it 'should output unix format' do - should run.with_params(sample_text).and_return(desired_output) + sample_text_doublebyte = "こんにちは\r\n世界\r\n" + desired_output_doublebyte = "こんにちは\n世界\n" + + it 'should output uft8 string' do + should run.with_params(sample_text_utf8).and_return(desired_output_utf8) + end + + it 'should output double byte string' do + should run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte) end end end diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 5d97684..6f94d72 100755 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -36,9 +36,16 @@ describe 'ensure_packages' do context 'given hash of packages' do before { subject.call([{"foo" => { "provider" => "rpm" }, "bar" => { "provider" => "gem" }}, { "ensure" => "present"}]) } + before { subject.call([{"パッケージ" => { "ensure" => "absent"}}]) } + before { subject.call([{"ρǻ¢κầģẻ" => { "ensure" => "absent"}}]) } # this lambda is required due to strangeness within rspec-puppet's expectation handling it { expect(lambda { catalogue }).to contain_package('foo').with({'provider' => 'rpm', 'ensure' => 'present'}) } it { expect(lambda { catalogue }).to contain_package('bar').with({'provider' => 'gem', 'ensure' => 'present'}) } + + context 'should run with UTF8 and double byte characters' do + it { expect(lambda { catalogue }).to contain_package('パッケージ').with({'ensure' => 'absent'}) } + it { expect(lambda { catalogue }).to contain_package('ρǻ¢κầģẻ').with({'ensure' => 'absent'}) } + end end end diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index d552f4e..fddc4c4 100755 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -38,7 +38,31 @@ describe 'ensure_resource' do it { expect(lambda { catalogue }).to contain_user('username1').with_ensure('present') } it { expect(lambda { catalogue }).to contain_user('username1').without_gid } end + end + + context 'given a catalog with UTF8 chars' do + describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", {})' do + before { subject.call(['User', 'Şắოрŀễ Ţëם', {}]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } + end + + describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { gid => undef })' do + before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'gid' => :undef }]) } + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_ensure } + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } + end + + describe 'after running ensure_resource("user", "Şắოрŀễ Ţëם", { ensure => present, gid => undef })' do + before { subject.call(['User', 'Şắოрŀễ Ţëם', { 'ensure' => 'present', 'gid' => :undef }]) } + + # this lambda is required due to strangeness within rspec-puppet's expectation handling + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').with_ensure('present') } + it { expect(lambda { catalogue }).to contain_user('Şắოрŀễ Ţëם').without_gid } + end end context 'given a catalog with "user { username1: ensure => present }"' do diff --git a/spec/functions/flatten_spec.rb b/spec/functions/flatten_spec.rb index a4338be..b80f3c5 100755 --- a/spec/functions/flatten_spec.rb +++ b/spec/functions/flatten_spec.rb @@ -11,4 +11,5 @@ describe 'flatten' do it { is_expected.to run.with_params([['one']]).and_return(['one']) } it { is_expected.to run.with_params(["a","b","c","d","e","f","g"]).and_return(["a","b","c","d","e","f","g"]) } it { is_expected.to run.with_params([["a","b",["c",["d","e"],"f","g"]]]).and_return(["a","b","c","d","e","f","g"]) } + it { is_expected.to run.with_params(["ã","β",["ĉ",["đ","ẽ","ƒ","ġ"]]]).and_return(["ã","β","ĉ","đ","ẽ","ƒ","ġ"]) } end diff --git a/spec/functions/fqdn_rand_string_spec.rb b/spec/functions/fqdn_rand_string_spec.rb index e407084..861a59e 100644 --- a/spec/functions/fqdn_rand_string_spec.rb +++ b/spec/functions/fqdn_rand_string_spec.rb @@ -20,6 +20,7 @@ describe 'fqdn_rand_string' do it { is_expected.to run.with_params(100, '').and_return(default_charset) } it { is_expected.to run.with_params(100, 'a').and_return(/\Aa{100}\z/) } it { is_expected.to run.with_params(100, 'ab').and_return(/\A[ab]{100}\z/) } + it { is_expected.to run.with_params(100, 'ãβ').and_return(/\A[ãβ]{100}\z/) } it "provides the same 'random' value on subsequent calls for the same host" do expect(fqdn_rand_string(10)).to eql(fqdn_rand_string(10)) diff --git a/spec/functions/fqdn_rotate_spec.rb b/spec/functions/fqdn_rotate_spec.rb index db7a717..7c1038a 100755 --- a/spec/functions/fqdn_rotate_spec.rb +++ b/spec/functions/fqdn_rotate_spec.rb @@ -7,6 +7,7 @@ describe 'fqdn_rotate' do it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work with/) } it { is_expected.to run.with_params('').and_return('') } it { is_expected.to run.with_params('a').and_return('a') } + it { is_expected.to run.with_params('ã').and_return('ã') } it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['a']).and_return(['a']) } diff --git a/spec/functions/fqdn_uuid_spec.rb b/spec/functions/fqdn_uuid_spec.rb index a2d1618..d0c30d6 100644 --- a/spec/functions/fqdn_uuid_spec.rb +++ b/spec/functions/fqdn_uuid_spec.rb @@ -10,5 +10,4 @@ describe 'fqdn_uuid' do it { should run.with_params('puppetlabs.com').and_return('9c70320f-6815-5fc5-ab0f-debe68bf764c') } it { should run.with_params('google.com').and_return('64ee70a4-8cc1-5d25-abf2-dea6c79a09c8') } end - end diff --git a/spec/functions/getparam_spec.rb b/spec/functions/getparam_spec.rb index e4ef9e6..522ed3b 100755 --- a/spec/functions/getparam_spec.rb +++ b/spec/functions/getparam_spec.rb @@ -24,4 +24,12 @@ describe 'getparam' do it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') } it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) } end + + describe 'when compared against a user resource with UTF8 and double byte params' do + let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' } + + it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') } + it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') } + + end end diff --git a/spec/functions/getvar_spec.rb b/spec/functions/getvar_spec.rb index 54f1842..55789d8 100755 --- a/spec/functions/getvar_spec.rb +++ b/spec/functions/getvar_spec.rb @@ -20,4 +20,19 @@ describe 'getvar' do it { is_expected.to run.with_params('::site::data::foo').and_return('baz') } it { is_expected.to run.with_params('::site::data::bar').and_return(nil) } end + + context 'given variables in namespaces' do + let(:pre_condition) { + <<-'ENDofPUPPETcode' + class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' } + class site::new { $item = '万Ü€‰' } + include site::info + include site::new + ENDofPUPPETcode + } + + it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') } + it { is_expected.to run.with_params('::site::new::item').and_return('万Ü€‰') } + end end + diff --git a/spec/functions/grep_spec.rb b/spec/functions/grep_spec.rb index 6e0bd6e..d2152b1 100755 --- a/spec/functions/grep_spec.rb +++ b/spec/functions/grep_spec.rb @@ -16,4 +16,5 @@ describe 'grep' do it { is_expected.to run.with_params([], 'two').and_return([]) } it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['two']) } it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['two', 'three']) } + it { is_expected.to run.with_params(['ờאּê', 'ţשּׂỡ', 'ţһŗəè'], 'ţ(שּׂỡ|һŗəè)').and_return(['ţשּׂỡ', 'ţһŗəè']) } end diff --git a/spec/functions/has_ip_network_spec.rb b/spec/functions/has_ip_network_spec.rb index 7b5fe66..57cf613 100755 --- a/spec/functions/has_ip_network_spec.rb +++ b/spec/functions/has_ip_network_spec.rb @@ -9,7 +9,6 @@ describe 'has_ip_network' do let(:facts) do { :interfaces => 'eth0,lo', - :network => :undefined, :network_lo => '127.0.0.0', :network_eth0 => '10.0.0.0', } diff --git a/spec/functions/has_key_spec.rb b/spec/functions/has_key_spec.rb index 965d5a6..0e0e1cc 100755 --- a/spec/functions/has_key_spec.rb +++ b/spec/functions/has_key_spec.rb @@ -12,4 +12,9 @@ describe 'has_key' do it { is_expected.to run.with_params({ 'key' => 'value' }, "key").and_return(true) } 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 + it { is_expected.to run.with_params({ 'κéỳ ' => '٧ậļųể' }, "κéỳ ").and_return(true) } + it { is_expected.to run.with_params({ 'キー' => '٧ậļųể' }, "キー").and_return(true) } + end end diff --git a/spec/functions/hash_spec.rb b/spec/functions/hash_spec.rb index 4fe99ce..092474b 100755 --- a/spec/functions/hash_spec.rb +++ b/spec/functions/hash_spec.rb @@ -10,5 +10,6 @@ describe 'hash' do it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, /Unable to compute/) } it { is_expected.to run.with_params([]).and_return({}) } it { is_expected.to run.with_params(['key1', 'value1']).and_return({ 'key1' => 'value1' }) } + it { is_expected.to run.with_params(['κ℮ұ1', '√āĺűẻ1']).and_return({ 'κ℮ұ1' => '√āĺűẻ1' }) } it { is_expected.to run.with_params(['key1', 'value1', 'key2', 'value2']).and_return({ 'key1' => 'value1', 'key2' => 'value2' }) } end diff --git a/spec/functions/intersection_spec.rb b/spec/functions/intersection_spec.rb index c0f6086..ec368a5 100755 --- a/spec/functions/intersection_spec.rb +++ b/spec/functions/intersection_spec.rb @@ -14,6 +14,7 @@ describe 'intersection' do it { is_expected.to run.with_params(['one'], []).and_return([]) } it { is_expected.to run.with_params(['one'], ['one']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } + it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ['ŧשợ', 'ţђŕẽё']).and_return(['ŧשợ', 'ţђŕẽё']) } it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['two', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['two', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three', 'four']).and_return(['two', 'three']) } diff --git a/spec/functions/is_a_spec.rb b/spec/functions/is_a_spec.rb index 8dec13f..2d6cb46 100644 --- a/spec/functions/is_a_spec.rb +++ b/spec/functions/is_a_spec.rb @@ -21,5 +21,10 @@ if Puppet.version.to_f >= 4.0 it 'fails when comparing an integer and a string' do is_expected.to run.with_params(5, String).and_return(false) end + + it 'suceeds when comparing an UTF8 and double byte characters' do + is_expected.to run.with_params('このテキスト', String).and_return(true) + is_expected.to run.with_params('ŧћịś ŧêχŧ', String).and_return(true) + end end end diff --git a/spec/functions/is_mac_address_spec.rb b/spec/functions/is_mac_address_spec.rb index 5f76a91..c1e33b8 100755 --- a/spec/functions/is_mac_address_spec.rb +++ b/spec/functions/is_mac_address_spec.rb @@ -9,6 +9,12 @@ describe 'is_mac_address' do it { is_expected.to run.with_params('00:00:00:00:00:0g').and_return(false) } 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 + it { is_expected.to run.with_params('ƒốưř').and_return(false) } + it { is_expected.to run.with_params('三+').and_return(false) } + end + it { pending "should properly typecheck its arguments" is_expected.to run.with_params(1).and_return(false) diff --git a/spec/functions/join_keys_to_values_spec.rb b/spec/functions/join_keys_to_values_spec.rb index c2bae5b..0a2a50c 100755 --- a/spec/functions/join_keys_to_values_spec.rb +++ b/spec/functions/join_keys_to_values_spec.rb @@ -11,6 +11,12 @@ describe 'join_keys_to_values' do it { is_expected.to run.with_params({}, ':').and_return([]) } 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 + it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, ':').and_return(['ҝẽγ:√ạĺűē']) } + it { is_expected.to run.with_params({ 'ҝẽγ' => '√ạĺűē' }, '万').and_return(['ҝẽγ万√ạĺűē']) } + end + it { is_expected.to run.with_params({ 'key' => nil }, ':').and_return(['key:']) } it 'should run join_keys_to_values(<hash with multiple keys>, ":") and return the proper array' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }, ':']) @@ -21,3 +27,4 @@ describe 'join_keys_to_values' do expect(result.sort).to eq(['key1 value1', 'key2 value2', 'key2 value3'].sort) end end + diff --git a/spec/functions/join_spec.rb b/spec/functions/join_spec.rb index a300571..98852d5 100755 --- a/spec/functions/join_spec.rb +++ b/spec/functions/join_spec.rb @@ -16,4 +16,5 @@ describe 'join' do it { is_expected.to run.with_params(['one'], ':').and_return('one') } it { is_expected.to run.with_params(['one', 'two', 'three']).and_return('onetwothree') } it { is_expected.to run.with_params(['one', 'two', 'three'], ':').and_return('one:two:three') } + it { is_expected.to run.with_params(['ōŋể', 'ŧשợ', 'ţђŕẽё'], ':').and_return('ōŋể:ŧשợ:ţђŕẽё') } end diff --git a/spec/functions/keys_spec.rb b/spec/functions/keys_spec.rb index 2e009dc..fc7d6d8 100755 --- a/spec/functions/keys_spec.rb +++ b/spec/functions/keys_spec.rb @@ -16,4 +16,9 @@ describe 'keys' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }]) expect(result).to match_array(['key1', 'key2']) end + + it 'should run with UTF8 and double byte characters' do + result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }]) + expect(result).to match_array(['ҝểү', 'キー']) + end end diff --git a/spec/functions/length.rb b/spec/functions/length.rb new file mode 100755 index 0000000..d1ab003 --- /dev/null +++ b/spec/functions/length.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe 'length' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(ArgumentError, /'length' expects 1 argument, got none/) } + it { is_expected.to run.with_params([], 'extra').and_raise_error(ArgumentError, /'length' expects 1 argument, got 2/) } + it { is_expected.to run.with_params(1).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Integer/) } + it { is_expected.to run.with_params(true).and_raise_error(ArgumentError, /expects a value of type String, Array, or Hash, got Boolean/) } + it { is_expected.to run.with_params('1').and_return(1) } + it { is_expected.to run.with_params('1.0').and_return(3) } + it { is_expected.to run.with_params([]).and_return(0) } + it { is_expected.to run.with_params(['a']).and_return(1) } + it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(4) } + + it { is_expected.to run.with_params({}).and_return(0) } + it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } + it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } + it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) } + + it { is_expected.to run.with_params('').and_return(0) } + it { is_expected.to run.with_params('a').and_return(1) } + it { is_expected.to run.with_params('abc').and_return(3) } + it { is_expected.to run.with_params('abcd').and_return(4) } + it { is_expected.to run.with_params('万').and_return(1) } + it { is_expected.to run.with_params('āβćđ').and_return(4) } + + context 'when using a class extending String' do + it 'should call its size method' do + value = AlsoString.new('asdfghjkl') + value.expects(:length).returns('foo') + expect(subject).to run.with_params(value).and_return('foo') + end + end +end diff --git a/spec/functions/load_module_metadata_spec.rb b/spec/functions/load_module_metadata_spec.rb index 1a61e2c..9496fcb 100755 --- a/spec/functions/load_module_metadata_spec.rb +++ b/spec/functions/load_module_metadata_spec.rb @@ -7,32 +7,55 @@ describe 'load_module_metadata' do describe "when calling with valid arguments" do before :each do - if RSpec.configuration.puppet_future - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') - else - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') - end + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end + + context "when calling with valid utf8 and double byte character arguments" do + before :each do + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš - +この文字"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"ĭďèʼnţĩƒіểя": "ċơņťęאּť ỡƒ ţħíš - +この文字"}') + end + it "should json parse the file" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true) - allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') + if Puppet::Util::Platform.windows? + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(true) + allow(File).to receive(:read).with('C:/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') + else + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(true) + allow(File).to receive(:read).with('/path/to/module/metadata.json').and_return('{"name": "spencer-science"}') + end result = subject.call(['science']) expect(result['name']).to eq('spencer-science') end it "should fail by default if there is no metadata.json" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + if Puppet::Util::Platform.windows? + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false) + else + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + end expect {subject.call(['science'])}.to raise_error(Puppet::ParseError) end it "should return nil if user allows empty metadata.json" do - allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') - allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + if Puppet::Util::Platform.windows? + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('C:/path/to/module/') + allow(File).to receive(:exists?).with('C:/path/to/module/metadata.json').and_return(false) + else + allow(scope).to receive(:function_get_module_path).with(['science']).and_return('/path/to/module/') + allow(File).to receive(:exists?).with('/path/to/module/metadata.json').and_return(false) + end result = subject.call(['science', true]) expect(result).to eq({}) end + end end end diff --git a/spec/functions/loadjson_spec.rb b/spec/functions/loadjson_spec.rb index a00dff9..dbef805 100644 --- a/spec/functions/loadjson_spec.rb +++ b/spec/functions/loadjson_spec.rb @@ -6,26 +6,37 @@ describe 'loadjson' do describe "when calling with valid arguments" do before :each do - if RSpec.configuration.puppet_future - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') - else - allow(File).to receive(:read).with(/\/stdlib\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') - end + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/, {:encoding=>"utf-8"}).and_return('{"name": "puppetlabs-stdlib"}') + allow(File).to receive(:read).with(/\/(stdlib|test)\/metadata.json/).and_return('{"name": "puppetlabs-stdlib"}') end context 'when a non-existing file is specified' do - let(:filename) { '/tmp/doesnotexist' } + let(:filename) { + if Puppet::Util::Platform.windows? + 'C:/tmp/doesnotexist' + else + '/tmp/doesnotexist' + end + } before { allow(File).to receive(:exists?).with(filename).and_return(false).once allow(PSON).to receive(:load).never } it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) } + it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) } + it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) } end context 'when an existing file is specified' do - let(:filename) { '/tmp/doesexist' } - let(:data) { { 'key' => 'value' } } - let(:json) { '{"key":"value"}' } + let(:filename) { + if Puppet::Util::Platform.windows? + 'C:/tmp/doesexist' + else + '/tmp/doesexist' + end + } + let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} } + let(:json) { '{"key":"value", {"ķęŷ":"νậŀųề" }, {"キー":"値" }' } before { allow(File).to receive(:exists?).with(filename).and_return(true).once allow(File).to receive(:read).with(filename).and_return(json).once @@ -36,7 +47,13 @@ describe 'loadjson' do end context 'when the file could not be parsed' do - let(:filename) { '/tmp/doesexist' } + let(:filename) { + if Puppet::Util::Platform.windows? + 'C:/tmp/doesexist' + else + '/tmp/doesexist' + end + } let(:json) { '{"key":"value"}' } before { allow(File).to receive(:exists?).with(filename).and_return(true).once diff --git a/spec/functions/loadyaml_spec.rb b/spec/functions/loadyaml_spec.rb index 9f16a1a..e9428e3 100755 --- a/spec/functions/loadyaml_spec.rb +++ b/spec/functions/loadyaml_spec.rb @@ -11,11 +11,13 @@ describe 'loadyaml' do YAML.expects(:load_file).never } it { is_expected.to run.with_params(filename, {'default' => 'value'}).and_return({'default' => 'value'}) } + it { is_expected.to run.with_params(filename, {'đẽƒằưļŧ' => '٧ẵłựέ'}).and_return({'đẽƒằưļŧ' => '٧ẵłựέ'}) } + it { is_expected.to run.with_params(filename, {'デフォルト' => '値'}).and_return({'デフォルト' => '値'}) } end context 'when an existing file is specified' do let(:filename) { '/tmp/doesexist' } - let(:data) { { 'key' => 'value' } } + let(:data) { { 'key' => 'value', 'ķęŷ' => 'νậŀųề', 'キー' => '値'} } before { File.expects(:exists?).with(filename).returns(true).once YAML.expects(:load_file).with(filename).returns(data).once diff --git a/spec/functions/lstrip_spec.rb b/spec/functions/lstrip_spec.rb index 981794e..a5a09ed 100755 --- a/spec/functions/lstrip_spec.rb +++ b/spec/functions/lstrip_spec.rb @@ -22,6 +22,7 @@ describe 'lstrip' do it { is_expected.to run.with_params('one ').and_return('one ') } it { is_expected.to run.with_params(' one ').and_return('one ') } it { is_expected.to run.with_params(' one ').and_return('one ') } + it { is_expected.to run.with_params(' ǿňè ').and_return('ǿňè ') } it { is_expected.to run.with_params("\tone ").and_return('one ') } it { is_expected.to run.with_params("\t one ").and_return('one ') } it { is_expected.to run.with_params("one \t").and_return("one \t") } diff --git a/spec/functions/member_spec.rb b/spec/functions/member_spec.rb index 527f887..8988632 100755 --- a/spec/functions/member_spec.rb +++ b/spec/functions/member_spec.rb @@ -17,5 +17,7 @@ describe 'member' do it { is_expected.to run.with_params(['one'], 'one').and_return(true) } it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } + it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ŧẅồ']).and_return(true) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } + it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ƒί√ə']).and_return(false) } end diff --git a/spec/functions/parsejson_spec.rb b/spec/functions/parsejson_spec.rb index a01f1f6..7b07e49 100755 --- a/spec/functions/parsejson_spec.rb +++ b/spec/functions/parsejson_spec.rb @@ -12,12 +12,12 @@ describe 'parsejson' do context 'with correct JSON data' do - it 'should be able to parse a JSON data with a Hash' do + it 'should be able to parse JSON data with a Hash' do is_expected.to run.with_params('{"a":"1","b":"2"}'). and_return({'a'=>'1', 'b'=>'2'}) end - it 'should be able to parse a JSON data with an Array' do + it 'should be able to parse JSON data with an Array' do is_expected.to run.with_params('["a","b","c"]'). and_return(['a', 'b', 'c']) end @@ -29,11 +29,16 @@ describe 'parsejson' do and_return({}) end - it 'should be able to parse a JSON data with a mixed structure' do + it 'should be able to parse JSON data with a mixed structure' do is_expected.to run.with_params('{"a":"1","b":2,"c":{"d":[true,false]}}'). and_return({'a' =>'1', 'b' => 2, 'c' => { 'd' => [true, false] } }) end + it 'should be able to parse JSON data with a UTF8 and double byte characters' do + is_expected.to run.with_params('{"×":"これ","ý":"記号","です":{"©":["Á","ß"]}}'). + and_return({'×' =>'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] } }) + end + it 'should not return the default value if the data was parsed correctly' do is_expected.to run.with_params('{"a":"1"}', 'default_value'). and_return({'a' => '1'}) diff --git a/spec/functions/parseyaml_spec.rb b/spec/functions/parseyaml_spec.rb index fa947ca..c2a138c 100755 --- a/spec/functions/parseyaml_spec.rb +++ b/spec/functions/parseyaml_spec.rb @@ -18,21 +18,26 @@ describe 'parseyaml' do and_return('just a string') end - it 'should be able to parse a YAML data with a Hash' do + it 'should be able to parse YAML data with a Hash' do is_expected.to run.with_params("---\na: '1'\nb: '2'\n"). and_return({'a' => '1', 'b' => '2'}) end - it 'should be able to parse a YAML data with an Array' do + it 'should be able to parse YAML data with an Array' do is_expected.to run.with_params("---\n- a\n- b\n- c\n"). and_return(['a', 'b', 'c']) end - it 'should be able to parse a YAML data with a mixed structure' do + it 'should be able to parse YAML data with a mixed structure' do is_expected.to run.with_params("---\na: '1'\nb: 2\nc:\n d:\n - :a\n - true\n - false\n"). and_return({'a' => '1', 'b' => 2, 'c' => {'d' => [:a, true, false]}}) end + it 'should be able to parse YAML data with a UTF8 and double byte characters' do + is_expected.to run.with_params("---\na: ×\nこれ: 記号\nです:\n ©:\n - Á\n - ß\n"). + and_return({"a"=>"×", "これ"=>"記号", "です"=>{"©"=>["Á", "ß"]} }) + end + it 'should not return the default value if the data was parsed correctly' do is_expected.to run.with_params("---\na: '1'\n", 'default_value'). and_return({'a' => '1'}) diff --git a/spec/functions/pick_default_spec.rb b/spec/functions/pick_default_spec.rb index e2fc64a..a7ffc86 100755 --- a/spec/functions/pick_default_spec.rb +++ b/spec/functions/pick_default_spec.rb @@ -5,6 +5,7 @@ describe 'pick_default' do it { is_expected.to run.with_params().and_raise_error(Puppet::Error, /Must receive at least one argument/) } it { is_expected.to run.with_params('one', 'two').and_return('one') } + it { is_expected.to run.with_params('ớņệ', 'ťωơ').and_return('ớņệ') } it { is_expected.to run.with_params('', 'two').and_return('two') } it { is_expected.to run.with_params(:undef, 'two').and_return('two') } it { is_expected.to run.with_params(:undefined, 'two').and_return('two') } @@ -13,6 +14,7 @@ describe 'pick_default' do [ '', :undef, :undefined, nil, {}, [], 1, 'default' ].each do |value| describe "when providing #{value.inspect} as default" do it { is_expected.to run.with_params('one', value).and_return('one') } + it { is_expected.to run.with_params('ớņệ', value).and_return('ớņệ') } it { is_expected.to run.with_params([], value).and_return([]) } it { is_expected.to run.with_params({}, value).and_return({}) } it { is_expected.to run.with_params(value, value).and_return(value) } diff --git a/spec/functions/pick_spec.rb b/spec/functions/pick_spec.rb index 2c7caa8..438553b 100755 --- a/spec/functions/pick_spec.rb +++ b/spec/functions/pick_spec.rb @@ -9,4 +9,9 @@ describe 'pick' do it { is_expected.to run.with_params(:undef, 'two').and_return('two') } 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 + it { is_expected.to run.with_params(nil, 'このテキスト').and_return('このテキスト') } + it { is_expected.to run.with_params('', 'ŝẳмрłề џţƒ8 ţẽם', 'このテキスト').and_return('ŝẳмрłề џţƒ8 ţẽם') } + end end diff --git a/spec/functions/prefix_spec.rb b/spec/functions/prefix_spec.rb index 3761022..5510c58 100755 --- a/spec/functions/prefix_spec.rb +++ b/spec/functions/prefix_spec.rb @@ -11,6 +11,7 @@ describe 'prefix' do it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, /expected second argument to be a String/) } it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['one', 2]).and_return(['one', '2']) } + it { is_expected.to run.with_params(['ớņệ', 2]).and_return(['ớņệ', '2']) } 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(['one'], 'pre').and_return(['preone']) } diff --git a/spec/functions/range_spec.rb b/spec/functions/range_spec.rb index 492cad4..ca569d5 100755 --- a/spec/functions/range_spec.rb +++ b/spec/functions/range_spec.rb @@ -79,6 +79,14 @@ describe 'range' do it { is_expected.to run.with_params('01', '04').and_return([1, 2, 3, 4]) } end + context 'with prefixed numbers as utf8 strings as bounds' do + it { is_expected.to run.with_params('ħөŝŧ01', 'ħөŝŧ04').and_return(['ħөŝŧ01', 'ħөŝŧ02', 'ħөŝŧ03', 'ħөŝŧ04']) } + end + + context 'with prefixed numbers as double byte character strings as bounds' do + it { is_expected.to run.with_params('ホスト01', 'ホスト04').and_return(['ホスト01', 'ホスト02', 'ホスト03', 'ホスト04']) } + end + context 'with dash-range syntax' do it { is_expected.to run.with_params('4-1').and_return([]) } it { is_expected.to run.with_params('1-1').and_return([1]) } diff --git a/spec/functions/regexpescape_spec.rb b/spec/functions/regexpescape_spec.rb index 6efa847..36dbe70 100644 --- a/spec/functions/regexpescape_spec.rb +++ b/spec/functions/regexpescape_spec.rb @@ -32,5 +32,10 @@ describe 'regexpescape' do it { is_expected.to run.with_params([]).and_return([]) } 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 + it { is_expected.to run.with_params(['ŏʼnε*']).and_return(['ŏʼnε\*']) } + it { is_expected.to run.with_params(['インターネット*']).and_return(['インターネット\*']) } + end end end diff --git a/spec/functions/reject_spec.rb b/spec/functions/reject_spec.rb index 4863050..86db7c7 100755 --- a/spec/functions/reject_spec.rb +++ b/spec/functions/reject_spec.rb @@ -16,4 +16,5 @@ describe 'reject' do it { is_expected.to run.with_params([], 'two').and_return([]) } it { is_expected.to run.with_params(['one', 'two', 'three'], 'two').and_return(['one', 'three']) } it { is_expected.to run.with_params(['one', 'two', 'three'], 't(wo|hree)').and_return(['one']) } + it { is_expected.to run.with_params(['όʼnệ', 'ţщồ', 'ţңяέέ'], 'ţ(щồ|ңяέέ)').and_return(['όʼnệ']) } end diff --git a/spec/functions/reverse_spec.rb b/spec/functions/reverse_spec.rb index e00dee9..79bc0ad 100755 --- a/spec/functions/reverse_spec.rb +++ b/spec/functions/reverse_spec.rb @@ -15,11 +15,13 @@ describe 'reverse' do it { is_expected.to run.with_params(['one']).and_return(['one']) } it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['three', 'two', 'one']) } it { is_expected.to run.with_params(['one', 'two', 'three', 'four']).and_return(['four', 'three', 'two', 'one']) } + 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('a').and_return('a') } it { is_expected.to run.with_params('abc').and_return('cba') } it { is_expected.to run.with_params('abcd').and_return('dcba') } + it { is_expected.to run.with_params('āβćđ').and_return('đćβā') } context 'when using a class extending String' do it 'should call its reverse method' do diff --git a/spec/functions/rstrip_spec.rb b/spec/functions/rstrip_spec.rb index d2efac8..a7663e2 100755 --- a/spec/functions/rstrip_spec.rb +++ b/spec/functions/rstrip_spec.rb @@ -22,6 +22,7 @@ describe 'rstrip' do it { is_expected.to run.with_params('one ').and_return('one') } it { is_expected.to run.with_params(' one ').and_return(' one') } it { is_expected.to run.with_params(' one ').and_return(' one') } + it { is_expected.to run.with_params(' ǿňè ').and_return(' ǿňè') } it { is_expected.to run.with_params("\tone ").and_return("\tone") } it { is_expected.to run.with_params("\t one ").and_return("\t one") } it { is_expected.to run.with_params("one\t").and_return('one') } diff --git a/spec/functions/seeded_rand_spec.rb b/spec/functions/seeded_rand_spec.rb index 38e134e..ac108f4 100644 --- a/spec/functions/seeded_rand_spec.rb +++ b/spec/functions/seeded_rand_spec.rb @@ -50,4 +50,9 @@ describe 'seeded_rand' do scope.function_seeded_rand([max, seed]) end + + context 'should run with UTF8 and double byte characters' do + it { is_expected.to run.with_params(1000, 'ǿňè')} + it { is_expected.to run.with_params(1000, '文字列')} + end end diff --git a/spec/functions/shell_escape_spec.rb b/spec/functions/shell_escape_spec.rb index 3061dec..77917dd 100644 --- a/spec/functions/shell_escape_spec.rb +++ b/spec/functions/shell_escape_spec.rb @@ -19,4 +19,9 @@ describe 'shell_escape' do it { is_expected.to run.with_params('~`!@#$%^&*()_+-=[]\{}|;\':",./<>?') .and_return('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') } end + + context 'should run 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 end diff --git a/spec/functions/shell_join_spec.rb b/spec/functions/shell_join_spec.rb index 6815f7c..46305bf 100644 --- a/spec/functions/shell_join_spec.rb +++ b/spec/functions/shell_join_spec.rb @@ -15,6 +15,11 @@ describe 'shell_join' do it { is_expected.to run.with_params(['foo', 'bar baz']).and_return('foo bar\ baz') } it { is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) .and_return('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') } + + context 'should run 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 end describe 'stringification' do diff --git a/spec/functions/shell_split_spec.rb b/spec/functions/shell_split_spec.rb index beeb977..f8f9c90 100644 --- a/spec/functions/shell_split_spec.rb +++ b/spec/functions/shell_split_spec.rb @@ -20,5 +20,10 @@ describe 'shell_split' do .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?']) } it { is_expected.to run.with_params('\~\`\!@\#\$ \%\^\&\*\(\)_\+-\= \[\]\\\\\{\}\|\;\\\':\" ,./\<\>\?') .and_return(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) } + + context 'should run 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 end end diff --git a/spec/functions/shuffle_spec.rb b/spec/functions/shuffle_spec.rb index ebc3a73..4673daa 100755 --- a/spec/functions/shuffle_spec.rb +++ b/spec/functions/shuffle_spec.rb @@ -26,6 +26,11 @@ describe 'shuffle' do 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 + it { is_expected.to run.with_params('ůţƒ8 ŧέχŧ şŧґíńģ').and_return('ģńş ůχţέƒŧí8ґŧŧ ') } + it { is_expected.to run.with_params('日本語の文字列').and_return('字本日語文列の') } + end + context 'when using a class extending String' do it { is_expected.to run.with_params(AlsoString.new('asdfghjkl')).and_return('lkhdsfajg') } end diff --git a/spec/functions/size_spec.rb b/spec/functions/size_spec.rb index c0047ee..2047423 100755 --- a/spec/functions/size_spec.rb +++ b/spec/functions/size_spec.rb @@ -19,11 +19,14 @@ describe 'size' do it { is_expected.to run.with_params({}).and_return(0) } it { is_expected.to run.with_params({'1' => '2'}).and_return(1) } it { is_expected.to run.with_params({'1' => '2', '4' => '4'}).and_return(2) } + it { is_expected.to run.with_params({'€' => '@', '竹' => 'ǿňè'}).and_return(2) } it { is_expected.to run.with_params('').and_return(0) } it { is_expected.to run.with_params('a').and_return(1) } it { is_expected.to run.with_params('abc').and_return(3) } it { is_expected.to run.with_params('abcd').and_return(4) } + it { is_expected.to run.with_params('万').and_return(1) } + it { is_expected.to run.with_params('āβćđ').and_return(4) } context 'when using a class extending String' do it 'should call its size method' do diff --git a/spec/functions/squeeze_spec.rb b/spec/functions/squeeze_spec.rb index 7f09c30..b267d9a 100755 --- a/spec/functions/squeeze_spec.rb +++ b/spec/functions/squeeze_spec.rb @@ -16,6 +16,12 @@ describe 'squeeze' do it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') } end + context 'should run 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('ậậậậậậậậậậậậậậậậậ語語語語©') } + end + context 'when squeezing values in an array' do it { is_expected.to run \ diff --git a/spec/functions/strip_spec.rb b/spec/functions/strip_spec.rb index 689b6dd..18e943d 100755 --- a/spec/functions/strip_spec.rb +++ b/spec/functions/strip_spec.rb @@ -30,5 +30,6 @@ describe 'strip' do it { is_expected.to run.with_params("\tone \t").and_return('one') } it { is_expected.to run.with_params("\t one \t").and_return('one') } it { is_expected.to run.with_params(' o n e ').and_return('o n e') } + it { is_expected.to run.with_params(' ỏŋέ ').and_return('ỏŋέ') } it { is_expected.to run.with_params(AlsoString.new(' one ')).and_return('one') } end diff --git a/spec/functions/suffix_spec.rb b/spec/functions/suffix_spec.rb index efba4ab..e0eafb1 100755 --- a/spec/functions/suffix_spec.rb +++ b/spec/functions/suffix_spec.rb @@ -15,6 +15,8 @@ describe 'suffix' do it { is_expected.to run.with_params([''], '').and_return(['']) } it { is_expected.to run.with_params(['one'], 'post').and_return(['onepost']) } it { is_expected.to run.with_params(['one', 'two', 'three'], 'post').and_return(['onepost', 'twopost', 'threepost']) } + it { is_expected.to run.with_params(['ỗńέ', 'ťשׂǿ', 'ŧҺř℮ə'], 'рổŝţ').and_return(['ỗńέрổŝţ', 'ťשׂǿрổŝţ', 'ŧҺř℮əрổŝţ']) } + it { is_expected.to run.with_params({}).and_return({}) } diff --git a/spec/functions/union_spec.rb b/spec/functions/union_spec.rb index cfd38b6..3f36f24 100755 --- a/spec/functions/union_spec.rb +++ b/spec/functions/union_spec.rb @@ -20,5 +20,6 @@ describe 'union' do it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'two', 'three']).and_return(['one', 'two', 'three']) } it { is_expected.to run.with_params(['one', 'two'], ['two', 'three'], ['one', 'three']).and_return(['one', 'two', 'three']) } it { is_expected.to run.with_params(['one', 'two'], ['three', 'four'], ['one', 'two', 'three'], ['four']).and_return(['one', 'two', 'three', 'four']) } + it { is_expected.to run.with_params(['ốńə', 'ţשׂợ'], ['ŧĥяếệ', 'ƒởųŗ'], ['ốńə', 'ţשׂợ', 'ŧĥяếệ'], ['ƒởųŗ']).and_return(['ốńə', 'ţשׂợ', 'ŧĥяếệ', 'ƒởųŗ']) } it 'should not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3', 1, 2]) end end diff --git a/spec/functions/unique_spec.rb b/spec/functions/unique_spec.rb index 24257a0..7955acb 100755 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -17,11 +17,13 @@ describe 'unique' do it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['a']).and_return(['a']) } it { is_expected.to run.with_params(['a', 'b', 'a']).and_return(['a', 'b']) } + it { is_expected.to run.with_params(['ã', 'ъ', 'ã']).and_return(['ã', 'ъ']) } end context 'when called with a string' do it { is_expected.to run.with_params('').and_return('') } it { is_expected.to run.with_params('a').and_return('a') } it { is_expected.to run.with_params('aaba').and_return('ab') } + it { is_expected.to run.with_params('ããъã').and_return('ãъ') } end end diff --git a/spec/functions/validate_cmd_spec.rb b/spec/functions/validate_cmd_spec.rb index ab0cbc9..c6559e8 100755 --- a/spec/functions/validate_cmd_spec.rb +++ b/spec/functions/validate_cmd_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'validate_cmd' do +describe 'validate_cmd', :unless => Puppet::Util::Platform.windows? do let(:touch) { File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' } describe 'signature validation' do diff --git a/spec/functions/validate_ipv6_address_spec.rb b/spec/functions/validate_ipv6_address_spec.rb index 78810d4..137db36 100755 --- a/spec/functions/validate_ipv6_address_spec.rb +++ b/spec/functions/validate_ipv6_address_spec.rb @@ -29,6 +29,13 @@ describe 'validate_ipv6_address' do it { is_expected.to run.with_params('3ffe:0505:0002::', '3ffe:0505:0002::2') } it { is_expected.to run.with_params('::1/64') } it { is_expected.to run.with_params('fe80::a00:27ff:fe94:44d6/64') } + it { is_expected.to run.with_params('fe80:0000:0000:0000:0204:61ff:fe9d:f156') } + it { is_expected.to run.with_params('fe80:0:0:0:204:61ff:fe9d:f156') } + it { is_expected.to run.with_params('fe80::204:61ff:fe9d:f156') } + it { is_expected.to run.with_params('fe80:0:0:0:0204:61ff:254.157.241.86') } + it { is_expected.to run.with_params('::1') } + it { is_expected.to run.with_params('fe80::') } + it { is_expected.to run.with_params('2001::') } end describe 'invalid inputs' do @@ -38,6 +45,9 @@ describe 'validate_ipv6_address' do it { is_expected.to run.with_params('0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('0.0.0.256').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('0.0.0.0.0').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } + it { is_expected.to run.with_params('::ffff:2.3.4').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } + it { is_expected.to run.with_params('::ffff:257.1.2.3').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } + it { is_expected.to run.with_params('::ffff:12345678901234567890.1.26').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('affe:beef').and_raise_error(Puppet::ParseError, /is not a valid IPv6/) } it { is_expected.to run.with_params('::1', {}).and_raise_error(Puppet::ParseError, /is not a string/) } it { is_expected.to run.with_params('::1', true).and_raise_error(Puppet::ParseError, /is not a string/) } diff --git a/spec/functions/validate_legacy_spec.rb b/spec/functions/validate_legacy_spec.rb index 50cb317..10b2aee 100644 --- a/spec/functions/validate_legacy_spec.rb +++ b/spec/functions/validate_legacy_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -if Puppet.version.to_f >= 4.0 +if Puppet.version.to_f >= 4.4 describe 'validate_legacy' do it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params.and_raise_error(ArgumentError) } diff --git a/spec/functions/values_at_spec.rb b/spec/functions/values_at_spec.rb index a8348f3..681c101 100755 --- a/spec/functions/values_at_spec.rb +++ b/spec/functions/values_at_spec.rb @@ -30,6 +30,11 @@ describe 'values_at' do it { is_expected.to run.with_params([0, 1, 2], 3).and_raise_error(Puppet::ParseError, /index exceeds array size/) } end + context 'when requesting a single item using UTF8 and double byte characters' do + it { is_expected.to run.with_params(['ẩ', 'β', 'с', 'ď'], 0).and_return(['ẩ']) } + it { is_expected.to run.with_params(['文', '字', 'の', '値'], 2).and_return(['の']) } + end + context 'when requesting multiple items' do it { is_expected.to run.with_params([0, 1, 2], [1, -1]).and_raise_error(Puppet::ParseError, /Unknown format of given index/) } it { is_expected.to run.with_params([0, 1, 2], [0, 2]).and_return([0, 2]) } diff --git a/spec/functions/values_spec.rb b/spec/functions/values_spec.rb index 4abf0bd..26c6dfb 100755 --- a/spec/functions/values_spec.rb +++ b/spec/functions/values_spec.rb @@ -16,4 +16,9 @@ describe 'values' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }]) expect(result).to match_array(['value1', 'value2', 'value2']) end + + it 'should run with UTF8 and double byte characters' do + result = subject.call([{ 'かぎ' => '使用', 'ҝĕұ' => '√ẩŀứệ', 'ҝĕұďŭрļǐçằťè' => '√ẩŀứệ' }]) + expect(result).to match_array(['使用', '√ẩŀứệ', '√ẩŀứệ']) + end end diff --git a/spec/functions/zip_spec.rb b/spec/functions/zip_spec.rb index abca7ee..e1ae8ee 100755 --- a/spec/functions/zip_spec.rb +++ b/spec/functions/zip_spec.rb @@ -12,4 +12,10 @@ describe 'zip' do it { is_expected.to run.with_params([1,2,3], [4,5,6]).and_return([[1,4], [2,5], [3,6]]) } it { is_expected.to run.with_params([1,2,3], [4,5,6], false).and_return([[1,4], [2,5], [3,6]]) } it { is_expected.to run.with_params([1,2,3], [4,5,6], true).and_return([1, 4, 2, 5, 3, 6]) } + + context 'should run 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 end + diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 8a1907f..4d85e7d 100755 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,36 +1,21 @@ #! /usr/bin/env ruby -S rspec +require 'puppet' require 'beaker-rspec' require 'beaker/puppet_install_helper' - -UNSUPPORTED_PLATFORMS = [] +require 'beaker/module_install_helper' run_puppet_install_helper +install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ /pe/i +install_module_on(hosts) +install_module_dependencies_on(hosts) RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) - # Readable test descriptions c.formatter = :documentation # Configure all nodes in nodeset c.before :suite do - if ENV['FUTURE_PARSER'] == 'yes' - default[:default_apply_opts] ||= {} - default[:default_apply_opts].merge!({:parser => 'future'}) - end - - copy_root_module_to(default, :source => proj_root, :module_name => 'stdlib') - end -end - -def is_future_parser_enabled? - if default[:type] == 'aio' || ENV['PUPPET_INSTALL_TYPE'] == 'agent' - return true - elsif default[:default_apply_opts] - return default[:default_apply_opts][:parser] == 'future' end - return false end def get_puppet_version diff --git a/spec/unit/puppet/type/file_line_spec.rb b/spec/unit/puppet/type/file_line_spec.rb index 48e2670..150149b 100755 --- a/spec/unit/puppet/type/file_line_spec.rb +++ b/spec/unit/puppet/type/file_line_spec.rb @@ -2,14 +2,28 @@ require 'spec_helper' require 'tempfile' describe Puppet::Type.type(:file_line) do + let :tmp_path do + if Puppet::Util::Platform.windows? + 'C:\tmp\path' + else + '/tmp/path' + end + end + let :my_path do + if Puppet::Util::Platform.windows? + 'C:\my\path' + else + '/my/path' + end + end let :file_line do - Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path') + Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => tmp_path) end it 'should accept a line and path' do file_line[:line] = 'my_line' expect(file_line[:line]).to eq('my_line') - file_line[:path] = '/my/path' - expect(file_line[:path]).to eq('/my/path') + file_line[:path] = my_path + expect(file_line[:path]).to eq(my_path) end it 'should accept a match regex' do file_line[:match] = '^foo.*$' @@ -19,7 +33,7 @@ describe Puppet::Type.type(:file_line) do expect { Puppet::Type.type(:file_line).new( :name => 'foo', - :path => '/my/path', + :path => my_path, :line => 'foo=bar', :match => '^bar=blah$' )}.not_to raise_error @@ -28,23 +42,41 @@ describe Puppet::Type.type(:file_line) do expect { Puppet::Type.type(:file_line).new( :name => 'foo', - :path => '/my/path', + :path => my_path, :line => 'foo=bar', :match => '^\s*foo=.*$' )}.not_to raise_error end + it 'should accept utf8 characters' do + expect { + Puppet::Type.type(:file_line).new( + :name => 'ƒồỗ', + :path => my_path, + :line => 'ƒồỗ=ьåя', + :match => '^ьåя=βļάħ$' + )}.not_to raise_error + end + it 'should accept double byte characters' do + expect { + Puppet::Type.type(:file_line).new( + :name => 'フーバー', + :path => my_path, + :line => 'この=それ', + :match => '^この=ああ$' + )}.not_to raise_error + end it 'should accept posix filenames' do - file_line[:path] = '/tmp/path' - expect(file_line[:path]).to eq('/tmp/path') + file_line[:path] = tmp_path + expect(file_line[:path]).to eq(tmp_path) end it 'should not accept unqualified path' do expect { file_line[:path] = 'file' }.to raise_error(Puppet::Error, /File paths must be fully qualified/) end it 'should require that a line is specified' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file') }.to raise_error(Puppet::Error, /line is a required attribute/) + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, /line is a required attribute/) end it 'should not require that a line is specified when matching for absence' do - expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => '/tmp/file', :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 end it 'should require that a file is specified' do expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, /path is a required attribute/) @@ -55,15 +87,20 @@ describe Puppet::Type.type(:file_line) do it 'should default to replace => true' do expect(file_line[:replace]).to eq :true end - + it 'should default to encoding => UTF-8' do + expect(file_line[:encoding]).to eq 'UTF-8' + end + it 'should accept encoding => iso-8859-1' do + expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :present, :encoding => 'iso-8859-1', :line => 'bar') }.not_to raise_error + end it "should autorequire the file it manages" do catalog = Puppet::Resource::Catalog.new - file = Puppet::Type.type(:file).new(:name => "/tmp/path") + file = Puppet::Type.type(:file).new(:name => tmp_path) catalog.add_resource file catalog.add_resource file_line relationship = file_line.autorequire.find do |rel| - (rel.source.to_s == "File[/tmp/path]") and (rel.target.to_s == file_line.to_s) + (rel.source.to_s == "File[#{tmp_path}]") and (rel.target.to_s == file_line.to_s) end expect(relationship).to be_a Puppet::Relationship end diff --git a/types/compat/ipv6.pp b/types/compat/ipv6.pp index 18b148d..8b82f1a 100644 --- a/types/compat/ipv6.pp +++ b/types/compat/ipv6.pp @@ -1 +1 @@ -type Stdlib::Compat::Ipv6 = Pattern[/^(?:(?:[\da-f]{1,4}:){7}[\da-f]{1,4}|((?:[\da-f]{1,4}:){6})(\d+)\.(\d+)\.(\d+)\.(\d+))$/] +type Stdlib::Compat::Ipv6 = Pattern[/\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/] |