From 6e0a43941e7f57488ca2de7d31935c600e2fd0a8 Mon Sep 17 00:00:00 2001 From: Helen Campbell Date: Fri, 18 May 2018 15:41:15 +0100 Subject: [PATCH] pdksync_heads/master-0-g34e3266 --- .gitignore | 1 + .pdkignore | 23 +++++++ .rubocop.yml | 12 +++- .travis.yml | 20 +++--- .yardopts | 1 + Gemfile | 62 +++---------------- Rakefile | 5 +- appveyor.yml | 17 ++--- lib/puppet/parser/functions/base64.rb | 4 +- metadata.json | 6 +- spec/acceptance/bool2num_spec.rb | 4 +- spec/acceptance/pw_hash_spec.rb | 2 +- .../acceptance/validate_absolute_path_spec.rb | 12 +--- spec/default_facts.yml | 8 +++ spec/functions/any2array_spec.rb | 6 +- spec/functions/any2bool_spec.rb | 2 +- spec/functions/camelcase_spec.rb | 2 +- spec/functions/capitalize_spec.rb | 2 +- spec/functions/chomp_spec.rb | 4 +- spec/functions/chop_spec.rb | 4 +- spec/functions/concat_spec.rb | 14 ++--- spec/functions/count_spec.rb | 4 +- spec/functions/delete_at_spec.rb | 2 +- spec/functions/delete_regex_spec.rb | 18 +++--- spec/functions/delete_spec.rb | 30 ++++----- spec/functions/delete_undef_values_spec.rb | 4 +- spec/functions/difference_spec.rb | 12 ++-- spec/functions/dig44_spec.rb | 14 ++--- spec/functions/downcase_spec.rb | 2 +- spec/functions/ensure_packages_spec.rb | 2 +- spec/functions/ensure_resource_spec.rb | 4 +- spec/functions/flatten_spec.rb | 6 +- spec/functions/grep_spec.rb | 6 +- spec/functions/hash_spec.rb | 4 +- spec/functions/intersection_spec.rb | 12 ++-- spec/functions/join_keys_to_values_spec.rb | 2 +- spec/functions/join_spec.rb | 6 +- spec/functions/keys_spec.rb | 4 +- spec/functions/length_spec.rb | 4 +- spec/functions/member_spec.rb | 8 +-- spec/functions/parsejson_spec.rb | 6 +- spec/functions/parseyaml_spec.rb | 4 +- spec/functions/prefix_spec.rb | 6 +- spec/functions/range_spec.rb | 22 +++---- spec/functions/reject_spec.rb | 6 +- spec/functions/reverse_spec.rb | 6 +- spec/functions/shell_join_spec.rb | 4 +- spec/functions/shell_split_spec.rb | 4 +- spec/functions/shuffle_spec.rb | 4 +- spec/functions/size_spec.rb | 4 +- spec/functions/sort_spec.rb | 2 +- spec/functions/suffix_spec.rb | 4 +- spec/functions/swapcase_spec.rb | 6 +- spec/functions/to_json_pretty_spec.rb | 4 +- spec/functions/to_json_spec.rb | 4 +- spec/functions/to_yaml_spec.rb | 4 +- spec/functions/type3x_spec.rb | 2 +- spec/functions/type_spec.rb | 2 +- spec/functions/union_spec.rb | 16 ++--- spec/functions/unique_spec.rb | 4 +- spec/functions/upcase_spec.rb | 2 +- spec/functions/validate_absolute_path_spec.rb | 25 +------- spec/functions/validate_slength_spec.rb | 8 +-- spec/functions/values_at_spec.rb | 4 +- spec/functions/values_spec.rb | 2 +- spec/functions/zip_spec.rb | 4 +- spec/spec_helper.rb | 6 ++ spec/type_aliases/absolute_path_spec.rb | 30 +-------- spec/type_aliases/base32_spec.rb | 17 +---- spec/type_aliases/base64_spec.rb | 6 +- spec/type_aliases/filemode_spec.rb | 9 +-- spec/type_aliases/filesource_spec.rb | 24 +------ spec/type_aliases/fqdn_spec.rb | 6 +- spec/type_aliases/host_spec.rb | 13 +--- spec/type_aliases/httpsurl_spec.rb | 8 +-- spec/type_aliases/httpurl_spec.rb | 11 +--- spec/type_aliases/unixpath_spec.rb | 10 +-- spec/type_aliases/windowspath_spec.rb | 11 +--- spec/unit/facter/pe_version_spec.rb | 2 +- .../parser/functions/enclose_ipv6_spec.rb | 2 +- 80 files changed, 254 insertions(+), 415 deletions(-) create mode 100644 .pdkignore create mode 100644 .yardopts create mode 100644 spec/default_facts.yml diff --git a/.gitignore b/.gitignore index 56efb9ca1..49bc2a401 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,5 @@ /tmp/ /vendor/ /convert_report.txt +/update_report.txt .DS_Store diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 000000000..49bc2a401 --- /dev/null +++ b/.pdkignore @@ -0,0 +1,23 @@ +.*.sw[op] +.metadata +.yardoc +.yardwarns +*.iml +/.bundle/ +/.idea/ +/.vagrant/ +/coverage/ +/bin/ +/doc/ +/Gemfile.local +/Gemfile.lock +/junit/ +/log/ +/pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/tmp/ +/vendor/ +/convert_report.txt +/update_report.txt +.DS_Store diff --git a/.rubocop.yml b/.rubocop.yml index 50220b4bc..bfd2cd1d5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,11 +8,14 @@ AllCops: Exclude: - bin/* - ".vendor/**/*" - - Gemfile - - Rakefile + - "**/Gemfile" + - "**/Rakefile" - pkg/**/* - spec/fixtures/**/* - vendor/**/* + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" Metrics/LineLength: Description: People have wide screens, use them. Max: 200 @@ -66,6 +69,11 @@ Style/SymbolArray: inherit_from: ".rubocop_todo.yml" RSpec/MessageSpies: EnforcedStyle: receive +Style/Documentation: + Exclude: + - lib/puppet/parser/functions/**/* +Style/WordArray: + EnforcedStyle: brackets Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: diff --git a/.travis.yml b/.travis.yml index 14288376f..76b202cef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ before_install: - bundle -v - rm -f Gemfile.lock - gem update --system - - gem update bundler - gem --version - bundle -v script: @@ -16,14 +15,15 @@ bundler_args: --without system_tests rvm: - 2.4.1 env: - - PUPPET_GEM_VERSION="~> 5.0" CHECK=spec + global: + - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0" matrix: fast_finish: true include: - bundler_args: dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/centos-7 rvm: 2.4.1 script: bundle exec rake beaker services: docker @@ -31,23 +31,17 @@ matrix: - bundler_args: dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04 rvm: 2.4.1 script: bundle exec rake beaker services: docker sudo: required - - env: CHECK=rubocop + env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - env: CHECK="syntax lint" + env: CHECK=parallel_spec - - env: CHECK=metadata_lint - - - env: CHECK=release_checks - - - env: CHECK=spec - - - env: PUPPET_GEM_VERSION="~> 4.0" CHECK=spec + env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec rvm: 2.1.9 branches: only: diff --git a/.yardopts b/.yardopts new file mode 100644 index 000000000..29c933bcf --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index 37597a303..a7ec8208c 100644 --- a/Gemfile +++ b/Gemfile @@ -28,11 +28,12 @@ group :development do gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4') gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-blacksmith", '~> 3.4', require: false + gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby] end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] @@ -49,73 +50,24 @@ puppet_type = gem_type(puppet_version) facter_version = ENV['FACTER_GEM_VERSION'] hiera_version = ENV['HIERA_GEM_VERSION'] -def puppet_older_than?(version) - puppet_version = ENV['PUPPET_GEM_VERSION'] - !puppet_version.nil? && - Gem::Version.correct?(puppet_version) && - Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup)) -end - gems = {} gems['puppet'] = location_for(puppet_version) # If facter or hiera versions have been specified via the environment -# variables, use those versions. If not, and if the puppet version is < 3.5.0, -# use known good versions of both for puppet < 3.5.0. -if facter_version - gems['facter'] = location_for(facter_version) -elsif puppet_type == :gem && puppet_older_than?('3.5.0') - gems['facter'] = ['>= 1.6.11', '<= 1.7.5', require: false] -end - -if hiera_version - gems['hiera'] = location_for(ENV['HIERA_GEM_VERSION']) -elsif puppet_type == :gem && puppet_older_than?('3.5.0') - gems['hiera'] = ['>= 1.0.0', '<= 1.3.0', require: false] -end +# variables -if Gem.win_platform? && (puppet_type != :gem || puppet_older_than?('3.5.0')) - # For Puppet gems < 3.5.0 (tested as far back as 3.0.0) on Windows - if puppet_type == :gem - gems['ffi'] = ['1.9.0', require: false] - gems['minitar'] = ['0.5.4', require: false] - gems['win32-eventlog'] = ['0.5.3', '<= 0.6.5', require: false] - gems['win32-process'] = ['0.6.5', '<= 0.7.5', require: false] - gems['win32-security'] = ['~> 0.1.2', '<= 0.2.5', require: false] - gems['win32-service'] = ['0.7.2', '<= 0.8.8', require: false] - else - gems['ffi'] = ['~> 1.9.0', require: false] - gems['minitar'] = ['~> 0.5.4', require: false] - gems['win32-eventlog'] = ['~> 0.5', '<= 0.6.5', require: false] - gems['win32-process'] = ['~> 0.6', '<= 0.7.5', require: false] - gems['win32-security'] = ['~> 0.1', '<= 0.2.5', require: false] - gems['win32-service'] = ['~> 0.7', '<= 0.8.8', require: false] - end - - gems['win32-dir'] = ['~> 0.3', '<= 0.4.9', require: false] - - if RUBY_VERSION.start_with?('1.') - gems['win32console'] = ['1.3.2', require: false] - # sys-admin was removed in Puppet 3.7.0 and doesn't compile under Ruby 2.x - gems['sys-admin'] = ['1.5.6', require: false] - end +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version - # Puppet < 3.7.0 requires these. - # Puppet >= 3.5.0 gem includes these as requirements. - # The following versions are tested to work with 3.0.0 <= puppet < 3.7.0. - gems['win32-api'] = ['1.4.8', require: false] - gems['win32-taskscheduler'] = ['0.2.2', require: false] - gems['windows-api'] = ['0.4.3', require: false] - gems['windows-pr'] = ['1.2.3', require: false] -elsif Gem.win_platform? +if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} # If we're using a Puppet gem on Windows which handles its own win32-xxx gem # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). gems['win32-dir'] = ['<= 0.4.9', require: false] gems['win32-eventlog'] = ['<= 0.6.5', require: false] gems['win32-process'] = ['<= 0.7.5', require: false] gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['<= 0.8.8', require: false] + gems['win32-service'] = ['0.8.8', require: false] end gems.each do |gem_name, gem_params| diff --git a/Rakefile b/Rakefile index a39cae2f0..ef5f69827 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,7 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' +require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send('disable_relative') + diff --git a/appveyor.yml b/appveyor.yml index 5fd5e8925..4a5b22752 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,4 @@ +--- version: 1.1.x.{build} skip_commits: message: /^\(?doc\)?.*/ @@ -12,29 +13,23 @@ environment: matrix: - RUBY_VERSION: 24-x64 - CHECK: syntax lint - - - RUBY_VERSION: 24-x64 - CHECK: metadata_lint - - - RUBY_VERSION: 24-x64 - CHECK: rubocop + CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - PUPPET_GEM_VERSION: ~> 4.0 RUBY_VERSION: 21 - CHECK: spec + CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 4.0 RUBY_VERSION: 21-x64 - CHECK: spec + CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24 - CHECK: spec + CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24-x64 - CHECK: spec + CHECK: parallel_spec matrix: fast_finish: true install: diff --git a/lib/puppet/parser/functions/base64.rb b/lib/puppet/parser/functions/base64.rb index 484c2f1a4..35114e7d4 100644 --- a/lib/puppet/parser/functions/base64.rb +++ b/lib/puppet/parser/functions/base64.rb @@ -19,7 +19,7 @@ module Puppet::Parser::Functions raise Puppet::ParseError, "base64(): Wrong number of arguments (#{args.length}; must be >= 2)" unless args.length >= 2 - actions = %w[encode decode] + actions = ['encode', 'decode'] unless actions.include?(args[0]) raise Puppet::ParseError, "base64(): the first argument must be one of 'encode' or 'decode'" @@ -29,7 +29,7 @@ module Puppet::Parser::Functions raise Puppet::ParseError, 'base64(): the second argument must be a string to base64' end - method = %w[default strict urlsafe] + method = ['default', 'strict', 'urlsafe'] chosen_method = if args.length <= 2 'default' diff --git a/metadata.json b/metadata.json index a9c683fd6..11fe5bb57 100644 --- a/metadata.json +++ b/metadata.json @@ -101,7 +101,7 @@ } ], "description": "Standard Library for Puppet Modules", - "pdk-version": "1.4.1", - "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.4.1-0-g52adbbb" + "pdk-version": "1.5.0", + "template-url": "https://github.com/puppetlabs/pdk-templates", + "template-ref": "heads/master-0-g34e3266" } diff --git a/spec/acceptance/bool2num_spec.rb b/spec/acceptance/bool2num_spec.rb index 2a6243519..bf6611e2b 100644 --- a/spec/acceptance/bool2num_spec.rb +++ b/spec/acceptance/bool2num_spec.rb @@ -2,7 +2,7 @@ describe 'bool2num function' do describe 'success' do - %w[false f 0 n no].each do |bool| + ['false', 'f', '0', 'n', 'no'].each do |bool| pp1 = <<-DOC $input = "#{bool}" $output = bool2num($input) @@ -15,7 +15,7 @@ end end - %w[true t 1 y yes].each do |bool| + ['true', 't', '1', 'y', 'yes'].each do |bool| pp2 = <<-DOC $input = "#{bool}" $output = bool2num($input) diff --git a/spec/acceptance/pw_hash_spec.rb b/spec/acceptance/pw_hash_spec.rb index f6e2928a8..9c0d716c6 100644 --- a/spec/acceptance/pw_hash_spec.rb +++ b/spec/acceptance/pw_hash_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper_acceptance' # Windows and OS X do not have useful implementations of crypt(3) -describe 'pw_hash function', :unless => %w[windows Darwin SLES].include?(fact('operatingsystem')) do +describe 'pw_hash function', :unless => ['windows', 'Darwin', 'SLES'].include?(fact('operatingsystem')) do describe 'success' do pp1 = <<-DOC $o = pw_hash('password', 'sha-512', 'salt') diff --git a/spec/acceptance/validate_absolute_path_spec.rb b/spec/acceptance/validate_absolute_path_spec.rb index 30464593f..9fa0f807f 100644 --- a/spec/acceptance/validate_absolute_path_spec.rb +++ b/spec/acceptance/validate_absolute_path_spec.rb @@ -2,17 +2,7 @@ describe 'validate_absolute_path function' do describe 'success' do - %w[ - C:/ - C:\\\\ - C:\\\\WINDOWS\\\\System32 - C:/windows/system32 - X:/foo/bar - X:\\\\foo\\\\bar - /var/tmp - /var/lib/puppet - /var/opt/../lib/puppet - ].each do |path| + ['C:/', 'C:\\\\', 'C:\\\\WINDOWS\\\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\\\foo\\\\bar', '/var/tmp', '/var/lib/puppet', '/var/opt/../lib/puppet'].each do |path| pp = <<-DOC $one = '#{path}' validate_absolute_path($one) diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 000000000..3248be5aa --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,8 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +concat_basedir: "/tmp" +ipaddress: "172.16.254.254" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/functions/any2array_spec.rb b/spec/functions/any2array_spec.rb index 345adc225..50edfafa1 100644 --- a/spec/functions/any2array_spec.rb +++ b/spec/functions/any2array_spec.rb @@ -5,12 +5,12 @@ it { is_expected.to run.with_params.and_return([]) } it { is_expected.to run.with_params(true).and_return([true]) } it { is_expected.to run.with_params('one').and_return(['one']) } - it { is_expected.to run.with_params('one', 'two').and_return(%w[one two]) } + it { is_expected.to run.with_params('one', 'two').and_return(['one', 'two']) } 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(%w[one two]).and_return(%w[one two]) } + it { is_expected.to run.with_params(['one', 'two']).and_return(['one', 'two']) } it { is_expected.to run.with_params({}).and_return([]) } - it { is_expected.to run.with_params('key' => 'value').and_return(%w[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(['竹']) } diff --git a/spec/functions/any2bool_spec.rb b/spec/functions/any2bool_spec.rb index eaead8f9f..4de9d216f 100644 --- a/spec/functions/any2bool_spec.rb +++ b/spec/functions/any2bool_spec.rb @@ -10,7 +10,7 @@ it { is_expected.to run.with_params('1.5').and_return(true) } describe 'when testing stringy values that mean "true"' do - %w[TRUE 1 t y true yes].each do |value| + ['TRUE', '1', 't', 'y', 'true', 'yes'].each do |value| it { is_expected.to run.with_params(value).and_return(true) } end end diff --git a/spec/functions/camelcase_spec.rb b/spec/functions/camelcase_spec.rb index 892e1da9c..92531c30c 100644 --- a/spec/functions/camelcase_spec.rb +++ b/spec/functions/camelcase_spec.rb @@ -12,6 +12,6 @@ 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(%w[abc aa_bb_cc]).and_return(%w[Abc AaBbCc]) } + it { is_expected.to run.with_params(['abc', 'aa_bb_cc']).and_return(['Abc', 'AaBbCc']) } it { is_expected.to run.with_params(['abc', 1, 'aa_bb_cc']).and_return(['Abc', 1, 'AaBbCc']) } end diff --git a/spec/functions/capitalize_spec.rb b/spec/functions/capitalize_spec.rb index 15c2acf0f..8884bb4f0 100644 --- a/spec/functions/capitalize_spec.rb +++ b/spec/functions/capitalize_spec.rb @@ -10,6 +10,6 @@ it { is_expected.to run.with_params(AlsoString.new('one')).and_return('One') } it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(%w[one two]).and_return(%w[One Two]) } + it { is_expected.to run.with_params(['one', 'two']).and_return(['One', 'Two']) } it { is_expected.to run.with_params(['one', 1, 'two']).and_return(['One', 1, 'Two']) } end diff --git a/spec/functions/chomp_spec.rb b/spec/functions/chomp_spec.rb index aabf5961d..880157309 100644 --- a/spec/functions/chomp_spec.rb +++ b/spec/functions/chomp_spec.rb @@ -11,12 +11,12 @@ it { is_expected.to run.with_params('one').and_return('one') } it { is_expected.to run.with_params("one\n").and_return('one') } it { is_expected.to run.with_params("one\n\n").and_return("one\n") } - it { is_expected.to run.with_params(%W[one\n two three\n]).and_return(%w[one two three]) } + it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'two', 'three']) } it { is_expected.to run.with_params(AlsoString.new('one')).and_return('one') } 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(%w[one two three]) } + it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'two', 'three']) } context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } diff --git a/spec/functions/chop_spec.rb b/spec/functions/chop_spec.rb index 7b7c5970b..d9e18ebe7 100644 --- a/spec/functions/chop_spec.rb +++ b/spec/functions/chop_spec.rb @@ -11,12 +11,12 @@ it { is_expected.to run.with_params('one').and_return('on') } it { is_expected.to run.with_params("one\n").and_return('one') } it { is_expected.to run.with_params("one\n\n").and_return("one\n") } - it { is_expected.to run.with_params(%W[one\n two three\n]).and_return(%w[one tw three]) } + it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'tw', 'three']) } it { is_expected.to run.with_params(AlsoString.new('one')).and_return('on') } 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(%w[one tw three]) } + it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'tw', 'three']) } context 'with UTF8 and double byte characters' do it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") } diff --git a/spec/functions/concat_spec.rb b/spec/functions/concat_spec.rb index c9f2ae50d..1df05bec2 100644 --- a/spec/functions/concat_spec.rb +++ b/spec/functions/concat_spec.rb @@ -6,18 +6,18 @@ it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError) } it { is_expected.to run.with_params(1, [2]).and_raise_error(Puppet::ParseError) } it { is_expected.to run.with_params([1], [2], [3]).and_return([1, 2, 3]) } - it { is_expected.to run.with_params(%w[1 2 3], %w[4 5 6]).and_return(%w[1 2 3 4 5 6]) } - it { is_expected.to run.with_params(%w[1 2 3], '4').and_return(%w[1 2 3 4]) } - it { is_expected.to run.with_params(%w[1 2 3], [%w[4 5], '6']).and_return(['1', '2', '3', %w[4 5], '6']) } - it { is_expected.to run.with_params(%w[1 2], %w[3 4], %w[5 6]).and_return(%w[1 2 3 4 5 6]) } - it { is_expected.to run.with_params(%w[1 2], '3', '4', %w[5 6]).and_return(%w[1 2 3 4 5 6]) } + 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').and_return(['1', '2', '3', '4']) } + 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 'with UTF8 and double byte characters' do it { is_expected.to run.with_params([{ 'a' => 'b' }], 'c' => 'd', 'e' => 'f').and_return([{ 'a' => 'b' }, { 'c' => 'd', 'e' => 'f' }]) } - it { is_expected.to run.with_params(['ấ', 'β', '©'], %w[đ ể 文字列]).and_return(['ấ', 'β', '©', 'đ', 'ể', '文字列']) } + it { is_expected.to run.with_params(['ấ', 'β', '©'], ['đ', 'ể', '文字列']).and_return(['ấ', 'β', '©', 'đ', 'ể', '文字列']) } end - arguments = [%w[1 2 3], %w[4 5 6]] + arguments = [['1', '2', '3'], ['4', '5', '6']] originals = [arguments[0].dup, arguments[1].dup] it 'leaves the original array intact' do _result = subject.call([arguments[0], arguments[1]]) diff --git a/spec/functions/count_spec.rb b/spec/functions/count_spec.rb index 9f5d54459..54e1491c4 100644 --- a/spec/functions/count_spec.rb +++ b/spec/functions/count_spec.rb @@ -10,8 +10,8 @@ is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError) } it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(ArgumentError) } - it { is_expected.to run.with_params(%w[one two three]).and_return(3) } - it { is_expected.to run.with_params(%w[one two two], 'two').and_return(2) } + it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(3) } + it { is_expected.to run.with_params(['one', 'two', 'two'], 'two').and_return(2) } 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) } diff --git a/spec/functions/delete_at_spec.rb b/spec/functions/delete_at_spec.rb index 8889fbc2a..fd246ffe1 100644 --- a/spec/functions/delete_at_spec.rb +++ b/spec/functions/delete_at_spec.rb @@ -18,7 +18,7 @@ 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(%w[ƒờở βāř ьầż], 1).and_return(%w[ƒờở ьầż]) } + it { is_expected.to run.with_params(['ƒờở', 'βāř', 'ьầż'], 1).and_return(['ƒờở', 'ьầż']) } it 'leaves the original array intact' do argument = [1, 2, 3] diff --git a/spec/functions/delete_regex_spec.rb b/spec/functions/delete_regex_spec.rb index 1e1cc2c4b..72abb12ba 100644 --- a/spec/functions/delete_regex_spec.rb +++ b/spec/functions/delete_regex_spec.rb @@ -14,13 +14,13 @@ it { is_expected.to run.with_params([], '').and_return([]) } it { is_expected.to run.with_params([], 'two').and_return([]) } it { is_expected.to run.with_params(['two'], 'two').and_return([]) } - it { is_expected.to run.with_params(%w[two two], 'two').and_return([]) } - it { is_expected.to run.with_params(%w[one two three], '^t.*').and_return(['one']) } - it { is_expected.to run.with_params(%w[ab b c b], 'b').and_return(%w[ab c]) } - it { is_expected.to run.with_params(%w[one two three], 'four').and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two three], 'e').and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two three], 'two').and_return(%w[one three]) } - it { is_expected.to run.with_params(%w[two one two three two], 'two').and_return(%w[one three]) } + it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) } + it { is_expected.to run.with_params(['one', 'two', 'three'], '^t.*').and_return(['one']) } + it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) } + it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) } + it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) } + 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(['abracadabra'], 'abr').and_return(['abracadabra']) } it { is_expected.to run.with_params(['abracadabra'], '^.*jimbob.*$').and_return(['abracadabra']) } end @@ -36,13 +36,13 @@ } it { is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, %w[key1 key2]) \ + .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, ['key1', 'key2']) \ .and_return('key3' => 'value3') } end it 'leaves the original array intact' do - argument1 = %w[one two three] + argument1 = ['one', 'two', 'three'] original1 = argument1.dup subject.call([argument1, 'two']) expect(argument1).to eq(original1) diff --git a/spec/functions/delete_spec.rb b/spec/functions/delete_spec.rb index fa2f1b8ef..ae447e5dc 100644 --- a/spec/functions/delete_spec.rb +++ b/spec/functions/delete_spec.rb @@ -12,14 +12,14 @@ it { is_expected.to run.with_params([], '').and_return([]) } it { is_expected.to run.with_params([], 'two').and_return([]) } it { is_expected.to run.with_params(['two'], 'two').and_return([]) } - it { is_expected.to run.with_params(%w[two two], 'two').and_return([]) } - it { is_expected.to run.with_params(%w[ab b c b], 'b').and_return(%w[ab c]) } - it { is_expected.to run.with_params(%w[one two three], 'four').and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two three], 'e').and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two three], 'two').and_return(%w[one three]) } - it { is_expected.to run.with_params(%w[two one two three two], 'two').and_return(%w[one three]) } - it { is_expected.to run.with_params(%w[one two three two], %w[one two]).and_return(['three']) } - it { is_expected.to run.with_params(['ồאּẻ', 'ŧẅơ', 'ŧңŗё℮', 'ŧẅơ'], %w[ồאּẻ ŧẅơ]).and_return(['ŧңŗё℮']) } + it { is_expected.to run.with_params(['two', 'two'], 'two').and_return([]) } + it { is_expected.to run.with_params(['ab', 'b', 'c', 'b'], 'b').and_return(['ab', 'c']) } + it { is_expected.to run.with_params(['one', 'two', 'three'], 'four').and_return(['one', 'two', 'three']) } + it { is_expected.to run.with_params(['one', 'two', 'three'], 'e').and_return(['one', 'two', 'three']) } + 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,11 +30,11 @@ it { is_expected.to run.with_params('barbar', 'bar').and_return('') } 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', %w[foo bar]).and_return('baz') } - it { is_expected.to run.with_params('ƒōōβậяβậβậяź', %w[ƒōō βậя]).and_return('βậź') } + it { is_expected.to run.with_params('foobarbabarz', ['foo', 'bar']).and_return('baz') } + it { is_expected.to run.with_params('ƒōōβậяβậβậяź', ['ƒōō', 'βậя']).and_return('βậź') } - it { is_expected.to run.with_params('barfoobar', %w[barbar foo]).and_return('barbar') } - it { is_expected.to run.with_params('barfoobar', %w[foo barbar]).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 describe 'deleting from an array' do @@ -48,18 +48,18 @@ } it { is_expected.to run \ - .with_params({ 'key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3' }, %w[key1 key2]) \ + .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' }, %w[ĸəұ1 ĸəұ2]) \ + .with_params({ 'ĸəұ1' => 'νãŀủĕ1', 'ĸəұ2' => 'νãŀủĕ2', 'ĸəұ3' => 'νãŀủĕ3' }, ['ĸəұ1', 'ĸəұ2']) \ .and_return('ĸəұ3' => 'νãŀủĕ3') } end it 'leaves the original array intact' do - argument1 = %w[one two three] + argument1 = ['one', 'two', 'three'] original1 = argument1.dup _result = subject.call([argument1, 'two']) expect(argument1).to eq(original1) diff --git a/spec/functions/delete_undef_values_spec.rb b/spec/functions/delete_undef_values_spec.rb index 2a282f5c8..be0ebfc88 100644 --- a/spec/functions/delete_undef_values_spec.rb +++ b/spec/functions/delete_undef_values_spec.rb @@ -15,8 +15,8 @@ pending("review behaviour when being passed undef as #{undef_value.inspect}") if undef_value.nil? 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(%w[one two three]) } - it { is_expected.to run.with_params(['ớņέ', undef_value, 'ŧשּׁō', 'ŧħґëə']).and_return(%w[ớņέ ŧשּׁō ŧħґëə]) } + 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 'leaves the original argument intact' do diff --git a/spec/functions/difference_spec.rb b/spec/functions/difference_spec.rb index d8c676587..127e7b173 100644 --- a/spec/functions/difference_spec.rb +++ b/spec/functions/difference_spec.rb @@ -14,10 +14,10 @@ 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(%w[one two three], %w[two three]).and_return(['one']) } - it { is_expected.to run.with_params(['ớņέ', 'ŧשּׁō', 'ŧħґëə', 2], %w[ŧשּׁō ŧħґëə]).and_return(['ớņέ', 2]) } - it { is_expected.to run.with_params(%w[one two two three], %w[two three]).and_return(['one']) } - it { is_expected.to run.with_params(%w[one two three], %w[two two three]).and_return(['one']) } - it { is_expected.to run.with_params(%w[one two three], %w[two three four]).and_return(['one']) } - it 'does not confuse types' do is_expected.to run.with_params(%w[1 2 3], [1, 2]).and_return(%w[1 2 3]) end + 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']) } + it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return(['1', '2', '3']) end end diff --git a/spec/functions/dig44_spec.rb b/spec/functions/dig44_spec.rb index c721b0cbf..6b830b968 100644 --- a/spec/functions/dig44_spec.rb +++ b/spec/functions/dig44_spec.rb @@ -80,11 +80,11 @@ context 'with structured values' do it 'is able to extract a deeply nested hash value' do - is_expected.to run.with_params(data, %w[a g], 'default').and_return('2') + is_expected.to run.with_params(data, ['a', 'g'], 'default').and_return('2') end it 'returns the default value if the path is too long' do - is_expected.to run.with_params(data, %w[a g c d], 'default').and_return('default') + is_expected.to run.with_params(data, ['a', 'g', 'c', 'd'], 'default').and_return('default') end it 'supports an array index (number) in the path' do @@ -92,23 +92,23 @@ end it 'supports an array index (string) in the path' do - is_expected.to run.with_params(data, %w[a e 1], 'default').and_return('f1') + is_expected.to run.with_params(data, ['a', 'e', '1'], 'default').and_return('f1') end it 'returns the default value if an array index is not a number' do - is_expected.to run.with_params(data, %w[a b c], 'default').and_return('default') + is_expected.to run.with_params(data, ['a', 'b', 'c'], 'default').and_return('default') end it 'returns the default value if and index is out of array length' do - is_expected.to run.with_params(data, %w[a e 5], 'default').and_return('default') + is_expected.to run.with_params(data, ['a', 'e', '5'], 'default').and_return('default') end it 'is able to path though both arrays and hashes' do - is_expected.to run.with_params(data, %w[a e 2 x y], 'default').and_return('z') + is_expected.to run.with_params(data, ['a', 'e', '2', 'x', 'y'], 'default').and_return('z') end it 'returns "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) + is_expected.to run.with_params(data, ['a', '1']).and_return(nil) end end diff --git a/spec/functions/downcase_spec.rb b/spec/functions/downcase_spec.rb index d49e16934..1cb1f35ad 100644 --- a/spec/functions/downcase_spec.rb +++ b/spec/functions/downcase_spec.rb @@ -10,6 +10,6 @@ it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('abc') } it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(%w[ONE TWO]).and_return(%w[one two]) } + it { is_expected.to run.with_params(['ONE', 'TWO']).and_return(['one', 'two']) } it { is_expected.to run.with_params(['One', 1, 'Two']).and_return(['one', 1, 'two']) } end diff --git a/spec/functions/ensure_packages_spec.rb b/spec/functions/ensure_packages_spec.rb index 6bdb015c6..78fa5f7d2 100644 --- a/spec/functions/ensure_packages_spec.rb +++ b/spec/functions/ensure_packages_spec.rb @@ -12,7 +12,7 @@ is_expected.to run.with_params(['packagename', 1]).and_raise_error(Puppet::ParseError) } it { is_expected.to run.with_params('packagename') } - it { is_expected.to run.with_params(%w[packagename1 packagename2]) } + it { is_expected.to run.with_params(['packagename1', 'packagename2']) } context 'when given a catalog with "package { puppet: ensure => absent }"' do let(:pre_condition) { 'package { puppet: ensure => absent }' } diff --git a/spec/functions/ensure_resource_spec.rb b/spec/functions/ensure_resource_spec.rb index 3ef3b70d4..27713910e 100644 --- a/spec/functions/ensure_resource_spec.rb +++ b/spec/functions/ensure_resource_spec.rb @@ -98,7 +98,7 @@ end describe 'after running ensure_resource("user", ["username1", "username2"], {})' do - before(:each) { subject.call(['User', %w[username1 username2], {}]) } + before(:each) { subject.call(['User', ['username1', 'username2'], {}]) } # this lambda is required due to strangeness within rspec-puppet's expectation handling it { expect(-> { catalogue }).to contain_user('username1').with_ensure('present') } @@ -108,7 +108,7 @@ describe 'when providing already set params' do let(:params) { { 'ensure' => 'present' } } - before(:each) { subject.call(['User', %w[username2 username3], params]) } + before(:each) { subject.call(['User', ['username2', 'username3'], params]) } # this lambda is required due to strangeness within rspec-puppet's expectation handling it { expect(-> { catalogue }).to contain_user('username1').with(params) } diff --git a/spec/functions/flatten_spec.rb b/spec/functions/flatten_spec.rb index df9ce34c5..16109e3a2 100644 --- a/spec/functions/flatten_spec.rb +++ b/spec/functions/flatten_spec.rb @@ -9,7 +9,7 @@ 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']]).and_return(['one']) } - it { is_expected.to run.with_params(%w[a b c d e f g]).and_return(%w[a b c d e f g]) } - it { is_expected.to run.with_params([['a', 'b', ['c', %w[d e], 'f', 'g']]]).and_return(%w[a b c d e f g]) } - it { is_expected.to run.with_params(['ã', 'β', ['ĉ', %w[đ ẽ ƒ ġ]]]).and_return(%w[ã β ĉ đ ẽ ƒ ġ]) } + 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/grep_spec.rb b/spec/functions/grep_spec.rb index 1122ffb18..587e51b8d 100644 --- a/spec/functions/grep_spec.rb +++ b/spec/functions/grep_spec.rb @@ -14,7 +14,7 @@ } it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(%w[one two three], 'two').and_return(['two']) } - it { is_expected.to run.with_params(%w[one two three], 't(wo|hree)').and_return(%w[two three]) } - it { is_expected.to run.with_params(%w[ờאּê ţשּׂỡ ţһŗəè], 'ţ(שּׂỡ|һŗəè)').and_return(%w[ţשּׂỡ ţһŗəè]) } + 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/hash_spec.rb b/spec/functions/hash_spec.rb index f32d54f29..2f78da4d3 100644 --- a/spec/functions/hash_spec.rb +++ b/spec/functions/hash_spec.rb @@ -9,7 +9,7 @@ } it { is_expected.to run.with_params(['one']).and_raise_error(Puppet::ParseError, %r{Unable to compute}) } it { is_expected.to run.with_params([]).and_return({}) } - it { is_expected.to run.with_params(%w[key1 value1]).and_return('key1' => 'value1') } + 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(%w[key1 value1 key2 value2]).and_return('key1' => 'value1', 'key2' => 'value2') } + 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 458992849..0ea871fb1 100644 --- a/spec/functions/intersection_spec.rb +++ b/spec/functions/intersection_spec.rb @@ -13,10 +13,10 @@ it { is_expected.to run.with_params([], ['one']).and_return([]) } 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(%w[one two three], %w[two three]).and_return(%w[two three]) } - it { is_expected.to run.with_params(%w[ōŋể ŧשợ ţђŕẽё], %w[ŧשợ ţђŕẽё]).and_return(%w[ŧשợ ţђŕẽё]) } - it { is_expected.to run.with_params(%w[one two two three], %w[two three]).and_return(%w[two three]) } - it { is_expected.to run.with_params(%w[one two three], %w[two two three]).and_return(%w[two three]) } - it { is_expected.to run.with_params(%w[one two three], %w[two three four]).and_return(%w[two three]) } - it 'does not confuse types' do is_expected.to run.with_params(%w[1 2 3], [1, 2]).and_return([]) end + 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']) } + it 'does not confuse types' do is_expected.to run.with_params(['1', '2', '3'], [1, 2]).and_return([]) end end diff --git a/spec/functions/join_keys_to_values_spec.rb b/spec/functions/join_keys_to_values_spec.rb index 8800499b2..655ae1e50 100644 --- a/spec/functions/join_keys_to_values_spec.rb +++ b/spec/functions/join_keys_to_values_spec.rb @@ -23,7 +23,7 @@ expect(result.sort).to eq(['key1:value1', 'key2:value2'].sort) end it 'runs join_keys_to_values(, " ") and return the proper array' do - result = subject.call([{ 'key1' => 'value1', 'key2' => %w[value2 value3] }, ' ']) + result = subject.call([{ 'key1' => 'value1', 'key2' => ['value2', 'value3'] }, ' ']) 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 c24ee7614..264ebc945 100644 --- a/spec/functions/join_spec.rb +++ b/spec/functions/join_spec.rb @@ -14,7 +14,7 @@ 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'], ':').and_return('one') } - it { is_expected.to run.with_params(%w[one two three]).and_return('onetwothree') } - it { is_expected.to run.with_params(%w[one two three], ':').and_return('one:two:three') } - it { is_expected.to run.with_params(%w[ōŋể ŧשợ ţђŕẽё], ':').and_return('ōŋể:ŧשợ:ţђŕẽё') } + 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 23a870e2d..2b538a018 100644 --- a/spec/functions/keys_spec.rb +++ b/spec/functions/keys_spec.rb @@ -14,11 +14,11 @@ it { is_expected.to run.with_params('key' => 'value').and_return(['key']) } it 'returns the array of keys' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2' }]) - expect(result).to match_array(%w[key1 key2]) + expect(result).to match_array(['key1', 'key2']) end it 'runs with UTF8 and double byte characters' do result = subject.call([{ 'ҝểү' => '√ẳŀμệ', 'キー' => '値' }]) - expect(result).to match_array(%w[ҝểү キー]) + expect(result).to match_array(['ҝểү', 'キー']) end end diff --git a/spec/functions/length_spec.rb b/spec/functions/length_spec.rb index 550c557ee..72ebb6205 100644 --- a/spec/functions/length_spec.rb +++ b/spec/functions/length_spec.rb @@ -10,8 +10,8 @@ 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(%w[one two three]).and_return(3) } - it { is_expected.to run.with_params(%w[one two three four]).and_return(4) } + 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) } diff --git a/spec/functions/member_spec.rb b/spec/functions/member_spec.rb index 410c4651d..f548bb564 100644 --- a/spec/functions/member_spec.rb +++ b/spec/functions/member_spec.rb @@ -16,8 +16,8 @@ it { is_expected.to run.with_params([], ['one']).and_return(false) } 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(%w[one two three four], %w[four two]).and_return(true) } - it { is_expected.to run.with_params(%w[ọאּẹ ŧẅồ ţҺŗęē ƒơџŕ], %w[ƒơџŕ ŧẅồ]).and_return(true) } - it { is_expected.to run.with_params(%w[one two three four], %w[four five]).and_return(false) } - it { is_expected.to run.with_params(%w[ọאּẹ ŧẅồ ţҺŗęē ƒơџŕ], ['ƒơџŕ', 'ƒί√ə']).and_return(false) } + 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 45abe3b0c..d03858479 100644 --- a/spec/functions/parsejson_spec.rb +++ b/spec/functions/parsejson_spec.rb @@ -18,11 +18,11 @@ it 'is able to parse JSON data with an Array' do is_expected.to run.with_params('["a","b","c"]') - .and_return(%w[a b c]) + .and_return(['a', 'b', 'c']) end it 'is able to parse empty JSON values' do - actual_array = %w[[] {}] + actual_array = ['[]', '{}'] expected = [[], {}] actual_array.each_with_index do |actual, index| is_expected.to run.with_params(actual).and_return(expected[index]) @@ -36,7 +36,7 @@ it 'is able to parse JSON data with a UTF8 and double byte characters' do is_expected.to run.with_params('{"×":"これ","ý":"記号","です":{"©":["Á","ß"]}}') - .and_return('×' => 'これ', 'ý' => '記号', 'です' => { '©' => %w[Á ß] }) + .and_return('×' => 'これ', 'ý' => '記号', 'です' => { '©' => ['Á', 'ß'] }) end it 'does not return the default value if the data was parsed correctly' do diff --git a/spec/functions/parseyaml_spec.rb b/spec/functions/parseyaml_spec.rb index bcf0afdca..e8d3f4ec1 100644 --- a/spec/functions/parseyaml_spec.rb +++ b/spec/functions/parseyaml_spec.rb @@ -25,7 +25,7 @@ it 'is able to parse YAML data with an Array' do is_expected.to run.with_params("---\n- a\n- b\n- c\n") - .and_return(%w[a b c]) + .and_return(['a', 'b', 'c']) end it 'is able to parse YAML data with a mixed structure' do @@ -35,7 +35,7 @@ it 'is 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' => '×', 'これ' => '記号', 'です' => { '©' => %w[Á ß] }) + .and_return('a' => '×', 'これ' => '記号', 'です' => { '©' => ['Á', 'ß'] }) end it 'does not return the default value if the data was parsed correctly' do diff --git a/spec/functions/prefix_spec.rb b/spec/functions/prefix_spec.rb index b4c61babf..1b771d916 100644 --- a/spec/functions/prefix_spec.rb +++ b/spec/functions/prefix_spec.rb @@ -10,12 +10,12 @@ it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{expected first argument to be an Array or a Hash}) } it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{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(%w[one 2]) } - it { is_expected.to run.with_params(['ớņệ', 2]).and_return(%w[ớņệ 2]) } + 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']) } - it { is_expected.to run.with_params(%w[one two three], 'pre').and_return(%w[preone pretwo prethree]) } + it { is_expected.to run.with_params(['one', 'two', 'three'], 'pre').and_return(['preone', 'pretwo', 'prethree']) } it { is_expected.to run.with_params({}).and_return({}) } it { is_expected.to run.with_params('key1' => 'value1', 2 => 3).and_return('key1' => 'value1', '2' => 3) } it { is_expected.to run.with_params({}, '').and_return({}) } diff --git a/spec/functions/range_spec.rb b/spec/functions/range_spec.rb index 1ae4adb1f..7b9e6d43c 100644 --- a/spec/functions/range_spec.rb +++ b/spec/functions/range_spec.rb @@ -62,18 +62,18 @@ context 'with characters as bounds' do it { is_expected.to run.with_params('d', 'a').and_return([]) } it { is_expected.to run.with_params('a', 'a').and_return(['a']) } - it { is_expected.to run.with_params('a', 'b').and_return(%w[a b]) } - it { is_expected.to run.with_params('a', 'd').and_return(%w[a b c d]) } - it { is_expected.to run.with_params('a', 'd', 1).and_return(%w[a b c d]) } - it { is_expected.to run.with_params('a', 'd', '1').and_return(%w[a b c d]) } - it { is_expected.to run.with_params('a', 'd', 2).and_return(%w[a c]) } - it { is_expected.to run.with_params('a', 'd', -2).and_return(%w[a c]) } - it { is_expected.to run.with_params('a', 'd', 3).and_return(%w[a d]) } + it { is_expected.to run.with_params('a', 'b').and_return(['a', 'b']) } + it { is_expected.to run.with_params('a', 'd').and_return(['a', 'b', 'c', 'd']) } + it { is_expected.to run.with_params('a', 'd', 1).and_return(['a', 'b', 'c', 'd']) } + it { is_expected.to run.with_params('a', 'd', '1').and_return(['a', 'b', 'c', 'd']) } + it { is_expected.to run.with_params('a', 'd', 2).and_return(['a', 'c']) } + it { is_expected.to run.with_params('a', 'd', -2).and_return(['a', 'c']) } + it { is_expected.to run.with_params('a', 'd', 3).and_return(['a', 'd']) } it { is_expected.to run.with_params('a', 'd', 4).and_return(['a']) } end context 'with strings as bounds' do - it { is_expected.to run.with_params('onea', 'oned').and_return(%w[onea oneb onec oned]) } + it { is_expected.to run.with_params('onea', 'oned').and_return(['onea', 'oneb', 'onec', 'oned']) } it { is_expected.to run.with_params('two', 'one').and_return([]) } it { is_expected.to run.with_params('true', 'false').and_return([]) } it { is_expected.to run.with_params('false', 'true').and_return(['false']) } @@ -106,16 +106,16 @@ end context 'with prefixed numbers as strings as bounds' do - it { is_expected.to run.with_params('host01', 'host04').and_return(%w[host01 host02 host03 host04]) } + it { is_expected.to run.with_params('host01', 'host04').and_return(['host01', 'host02', 'host03', 'host04']) } 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(%w[ħөŝŧ01 ħөŝŧ02 ħөŝŧ03 ħөŝŧ04]) } + 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(%w[ホスト01 ホスト02 ホスト03 ホスト04]) } + it { is_expected.to run.with_params('ホスト01', 'ホスト04').and_return(['ホスト01', 'ホスト02', 'ホスト03', 'ホスト04']) } end context 'with dash-range syntax' do diff --git a/spec/functions/reject_spec.rb b/spec/functions/reject_spec.rb index f083e746c..b7f6d2ed7 100644 --- a/spec/functions/reject_spec.rb +++ b/spec/functions/reject_spec.rb @@ -14,7 +14,7 @@ is_expected.to run.with_params(1, 'two').and_raise_error(Puppet::ParseError, %r{first argument not an array}) } it { is_expected.to run.with_params([], 'two').and_return([]) } - it { is_expected.to run.with_params(%w[one two three], 'two').and_return(%w[one three]) } - it { is_expected.to run.with_params(%w[one two three], 't(wo|hree)').and_return(['one']) } - it { is_expected.to run.with_params(%w[όʼnệ ţщồ ţңяέέ], 'ţ(щồ|ңяέέ)').and_return(['όʼnệ']) } + 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 6573fa744..b0728be16 100644 --- a/spec/functions/reverse_spec.rb +++ b/spec/functions/reverse_spec.rb @@ -13,9 +13,9 @@ 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(['one']).and_return(['one']) } - it { is_expected.to run.with_params(%w[one two three]).and_return(%w[three two one]) } - it { is_expected.to run.with_params(%w[one two three four]).and_return(%w[four three two one]) } - it { is_expected.to run.with_params(%w[ổňë ťŵọ ŧңяəė ƒŏůŗ]).and_return(%w[ƒŏůŗ ŧңяəė ťŵọ ổňë]) } + 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') } diff --git a/spec/functions/shell_join_spec.rb b/spec/functions/shell_join_spec.rb index b1f7ff2c4..a31352a56 100644 --- a/spec/functions/shell_join_spec.rb +++ b/spec/functions/shell_join_spec.rb @@ -11,7 +11,7 @@ describe 'shell argument joining' do it { is_expected.to run.with_params(['foo']).and_return('foo') } - it { is_expected.to run.with_params(%w[foo bar]).and_return('foo bar') } + it { is_expected.to run.with_params(['foo', 'bar']).and_return('foo bar') } it { is_expected.to run.with_params(['foo', 'bar baz']).and_return('foo bar\ baz') } it { is_expected.to run.with_params(['~`!@#$', '%^&*()_+-=', '[]\{}|;\':"', ',./<>?']) @@ -19,7 +19,7 @@ } context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(%w[μťƒ 8 ŧĕχť]).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') } + it { is_expected.to run.with_params(['μťƒ', '8', 'ŧĕχť']).and_return('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť') } it { is_expected.to run.with_params(['スペー', 'スを含むテ', ' キスト']).and_return('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト') } end end diff --git a/spec/functions/shell_split_spec.rb b/spec/functions/shell_split_spec.rb index beda04322..4a72cab2f 100644 --- a/spec/functions/shell_split_spec.rb +++ b/spec/functions/shell_split_spec.rb @@ -15,7 +15,7 @@ describe 'shell line spliting' do it { is_expected.to run.with_params('foo').and_return(['foo']) } - it { is_expected.to run.with_params('foo bar').and_return(%w[foo bar]) } + it { is_expected.to run.with_params('foo bar').and_return(['foo', 'bar']) } it { is_expected.to run.with_params('\~\`\!@\#\$\%\^\&\*\(\)_\+-\=\[\]\\\\\{\}\|\;\\\':\",./\<\>\?') .and_return(['~`!@#$%^&*()_+-=[]\{}|;\':",./<>?']) @@ -26,7 +26,7 @@ } context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(%w[μťƒ 8 ŧĕχť]) } + it { is_expected.to run.with_params('\\μ\\ť\\ƒ 8 \\ŧ\\ĕ\\χ\\ť').and_return(['μťƒ', '8', 'ŧĕχť']) } it { is_expected.to run.with_params('\\ス\\ペ\\ー \\ス\\を\\含\\む\\テ \\ \\キ\\ス\\ト').and_return(['スペー', 'スを含むテ', ' キスト']) } end end diff --git a/spec/functions/shuffle_spec.rb b/spec/functions/shuffle_spec.rb index eba3afa63..a3b68a856 100644 --- a/spec/functions/shuffle_spec.rb +++ b/spec/functions/shuffle_spec.rb @@ -18,8 +18,8 @@ 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(['one']).and_return(['one']) } - it { is_expected.to run.with_params(%w[one two three]).and_return(%w[two one three]) } - it { is_expected.to run.with_params(%w[one two three four]).and_return(%w[four three two one]) } + it { is_expected.to run.with_params(['one', 'two', 'three']).and_return(['two', 'one', 'three']) } + 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('a').and_return('a') } diff --git a/spec/functions/size_spec.rb b/spec/functions/size_spec.rb index a4079ea5b..b2b789782 100644 --- a/spec/functions/size_spec.rb +++ b/spec/functions/size_spec.rb @@ -13,8 +13,8 @@ it { is_expected.to run.with_params('1.0').and_raise_error(Puppet::ParseError, %r{Requires either string, array or hash to work}) } 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(%w[one two three]).and_return(3) } - it { is_expected.to run.with_params(%w[one two three four]).and_return(4) } + 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) } diff --git a/spec/functions/sort_spec.rb b/spec/functions/sort_spec.rb index f21d19fd3..7d4660d04 100644 --- a/spec/functions/sort_spec.rb +++ b/spec/functions/sort_spec.rb @@ -22,7 +22,7 @@ context 'when called with an array' do it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(%w[c b a]).and_return(%w[a b c]) } + it { is_expected.to run.with_params(['c', 'b', 'a']).and_return(['a', 'b', 'c']) } end context 'when called with a string' do diff --git a/spec/functions/suffix_spec.rb b/spec/functions/suffix_spec.rb index f4d5bc1d3..bbd1186d7 100644 --- a/spec/functions/suffix_spec.rb +++ b/spec/functions/suffix_spec.rb @@ -10,11 +10,11 @@ it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{expected first argument to be an Array}) } it { is_expected.to run.with_params([], 2).and_raise_error(Puppet::ParseError, %r{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(%w[one 2]) } + it { is_expected.to run.with_params(['one', 2]).and_return(['one', '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'], 'post').and_return(['onepost']) } - it { is_expected.to run.with_params(%w[one two three], 'post').and_return(%w[onepost twopost threepost]) } + 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 { diff --git a/spec/functions/swapcase_spec.rb b/spec/functions/swapcase_spec.rb index a970d71c2..837014060 100644 --- a/spec/functions/swapcase_spec.rb +++ b/spec/functions/swapcase_spec.rb @@ -23,9 +23,9 @@ 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(%w[one ONE]).and_return(%w[ONE one]) } - it { is_expected.to run.with_params(%w[ONE OnE]).and_return(%w[one oNe]) } - it { is_expected.to run.with_params(%w[oNe one]).and_return(%w[OnE ONE]) } + it { is_expected.to run.with_params(['one', 'ONE']).and_return(['ONE', 'one']) } + it { is_expected.to run.with_params(['ONE', 'OnE']).and_return(['one', 'oNe']) } + it { is_expected.to run.with_params(['oNe', 'one']).and_return(['OnE', 'ONE']) } end describe 'containing mixed types' do it { is_expected.to run.with_params(['OnE', {}]).and_return(['oNe', {}]) } diff --git a/spec/functions/to_json_pretty_spec.rb b/spec/functions/to_json_pretty_spec.rb index a8da623c4..7a7c44d13 100644 --- a/spec/functions/to_json_pretty_spec.rb +++ b/spec/functions/to_json_pretty_spec.rb @@ -4,11 +4,11 @@ it { is_expected.not_to eq(nil) } it { is_expected.to run.with_params([]).and_return("[\n\n]\n") } it { is_expected.to run.with_params(['one']).and_return("[\n \"one\"\n]\n") } - it { is_expected.to run.with_params(%w[one two]).and_return("[\n \"one\",\n \"two\"\n]\n") } + it { is_expected.to run.with_params(['one', 'two']).and_return("[\n \"one\",\n \"two\"\n]\n") } it { is_expected.to run.with_params({}).and_return("{\n}\n") } it { is_expected.to run.with_params('key' => 'value').and_return("{\n \"key\": \"value\"\n}\n") } it { - is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => %w[twoA twoB]) + is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB']) .and_return("{\n \"one\": {\n \"oneA\": \"A\",\n \"oneB\": {\n \"oneB1\": \"1\",\n \"oneB2\": \"2\"\n }\n },\n \"two\": [\n \"twoA\",\n \"twoB\"\n ]\n}\n") # rubocop:disable Metrics/LineLength : Unable to reduce line to required length } it { is_expected.to run.with_params({ 'one' => '1', 'two' => nil }, true).and_return("{\n \"one\": \"1\"\n}\n") } diff --git a/spec/functions/to_json_spec.rb b/spec/functions/to_json_spec.rb index 187ca3c94..83bb8866a 100644 --- a/spec/functions/to_json_spec.rb +++ b/spec/functions/to_json_spec.rb @@ -7,11 +7,11 @@ 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(['one']).and_return('["one"]') } - it { is_expected.to run.with_params(%w[one two]).and_return('["one","two"]') } + it { is_expected.to run.with_params(['one', 'two']).and_return('["one","two"]') } 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('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => %w[twoA twoB]) + is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB']) .and_return('{"one":{"oneA":"A","oneB":{"oneB1":"1","oneB2":"2"}},"two":["twoA","twoB"]}') } diff --git a/spec/functions/to_yaml_spec.rb b/spec/functions/to_yaml_spec.rb index 16948f61a..6c0855c6d 100644 --- a/spec/functions/to_yaml_spec.rb +++ b/spec/functions/to_yaml_spec.rb @@ -7,11 +7,11 @@ it { is_expected.to run.with_params('one').and_return("--- one\n...\n") } it { is_expected.to run.with_params([]).and_return("--- []\n") } it { is_expected.to run.with_params(['one']).and_return("---\n- one\n") } - it { is_expected.to run.with_params(%w[one two]).and_return("---\n- one\n- two\n") } + it { is_expected.to run.with_params(['one', 'two']).and_return("---\n- one\n- two\n") } it { is_expected.to run.with_params({}).and_return("--- {}\n") } it { is_expected.to run.with_params('key' => 'value').and_return("---\nkey: value\n") } it { - is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => %w[twoA twoB]) + is_expected.to run.with_params('one' => { 'oneA' => 'A', 'oneB' => { 'oneB1' => '1', 'oneB2' => '2' } }, 'two' => ['twoA', 'twoB']) .and_return("---\none:\n oneA: A\n oneB:\n oneB1: '1'\n oneB2: '2'\ntwo:\n- twoA\n- twoB\n") } diff --git a/spec/functions/type3x_spec.rb b/spec/functions/type3x_spec.rb index 3a71ed9f0..a53362d72 100644 --- a/spec/functions/type3x_spec.rb +++ b/spec/functions/type3x_spec.rb @@ -15,7 +15,7 @@ end it 'returns array when given an array' do - result = scope.function_type3x([%w[aaabbbbcccc asdf]]) + result = scope.function_type3x([['aaabbbbcccc', 'asdf']]) expect(result).to(eq('array')) end diff --git a/spec/functions/type_spec.rb b/spec/functions/type_spec.rb index a28a91338..37eb92e59 100644 --- a/spec/functions/type_spec.rb +++ b/spec/functions/type_spec.rb @@ -16,7 +16,7 @@ end it 'returns array when given an array' do - result = scope.function_type([%w[aaabbbbcccc asdf]]) + result = scope.function_type([['aaabbbbcccc', 'asdf']]) expect(result).to(eq('array')) end diff --git a/spec/functions/union_spec.rb b/spec/functions/union_spec.rb index d8dfc4fa8..549229808 100644 --- a/spec/functions/union_spec.rb +++ b/spec/functions/union_spec.rb @@ -14,12 +14,12 @@ 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'], ['one']).and_return(['one']) } - it { is_expected.to run.with_params(['one'], ['two']).and_return(%w[one two]) } - it { is_expected.to run.with_params(%w[one two three], %w[two three]).and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two two three], %w[two three]).and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two three], %w[two two three]).and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two], %w[two three], %w[one three]).and_return(%w[one two three]) } - it { is_expected.to run.with_params(%w[one two], %w[three four], %w[one two three], ['four']).and_return(%w[one two three four]) } - it { is_expected.to run.with_params(%w[ốńə ţשׂợ], %w[ŧĥяếệ ƒởųŗ], %w[ốńə ţשׂợ ŧĥяếệ], ['ƒởųŗ']).and_return(%w[ốńə ţשׂợ ŧĥяếệ ƒởųŗ]) } - it 'does not confuse types' do is_expected.to run.with_params(%w[1 2 3], [1, 2]).and_return(['1', '2', '3', 1, 2]) end + it { is_expected.to run.with_params(['one'], ['two']).and_return(['one', 'two']) } + it { is_expected.to run.with_params(['one', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) } + it { is_expected.to run.with_params(['one', 'two', 'two', 'three'], ['two', 'three']).and_return(['one', 'two', 'three']) } + 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 'does 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 b8481e029..1cdb93451 100644 --- a/spec/functions/unique_spec.rb +++ b/spec/functions/unique_spec.rb @@ -17,8 +17,8 @@ context 'when called with an array' do it { is_expected.to run.with_params([]).and_return([]) } it { is_expected.to run.with_params(['a']).and_return(['a']) } - it { is_expected.to run.with_params(%w[a b a]).and_return(%w[a b]) } - it { is_expected.to run.with_params(%w[ã ъ ã]).and_return(%w[ã ъ]) } + 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 diff --git a/spec/functions/upcase_spec.rb b/spec/functions/upcase_spec.rb index 2ef52824a..183c403aa 100644 --- a/spec/functions/upcase_spec.rb +++ b/spec/functions/upcase_spec.rb @@ -21,6 +21,6 @@ describe 'strings in arrays handling' do it { is_expected.to run.with_params([]).and_return([]) } - it { is_expected.to run.with_params(%w[One twO]).and_return(%w[ONE TWO]) } + it { is_expected.to run.with_params(['One', 'twO']).and_return(['ONE', 'TWO']) } end end diff --git a/spec/functions/validate_absolute_path_spec.rb b/spec/functions/validate_absolute_path_spec.rb index 5e93bb37f..75d194fc2 100644 --- a/spec/functions/validate_absolute_path_spec.rb +++ b/spec/functions/validate_absolute_path_spec.rb @@ -18,19 +18,7 @@ end describe 'valid paths handling' do - %w[ - C:/ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - //host/windows - / - /var/tmp - /var/opt/../lib/puppet - ].each do |path| + ['C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/', '/var/tmp', '/var/opt/../lib/puppet'].each do |path| it { is_expected.to run.with_params(path) } it { is_expected.to run.with_params(['/tmp', path]) } end @@ -53,16 +41,7 @@ end context 'with relative paths' do - %w[ - relative1 - . - .. - ./foo - ../foo - etc/puppetlabs/puppet - opt/puppet/bin - relative\\windows - ].each do |path| + ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'opt/puppet/bin', 'relative\\windows'].each do |path| it { is_expected.to run.with_params(path).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } it { is_expected.to run.with_params([path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } it { is_expected.to run.with_params(['/tmp', path]).and_raise_error(Puppet::ParseError, %r{is not an absolute path}) } diff --git a/spec/functions/validate_slength_spec.rb b/spec/functions/validate_slength_spec.rb index bde989b66..8d37bcb64 100644 --- a/spec/functions/validate_slength_spec.rb +++ b/spec/functions/validate_slength_spec.rb @@ -28,13 +28,13 @@ describe 'rejects strings longer than the limit' do it { is_expected.to run.with_params('1234567890a', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } it { is_expected.to run.with_params('1234567890abcdef', 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } - it { is_expected.to run.with_params(%w[one 1234567890abcdef], 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } + it { is_expected.to run.with_params(['one', '1234567890abcdef'], 10).and_raise_error(Puppet::ParseError, %r{Expected length}) } end describe 'accepts strings shorter or equal to the limit' do it { is_expected.to run.with_params('1234567890', 10) } it { is_expected.to run.with_params('12345', 10) } - it { is_expected.to run.with_params(%w[one two], 10) } + it { is_expected.to run.with_params(['one', 'two'], 10) } end end @@ -46,7 +46,7 @@ describe 'rejects numbers shorter than the lower limit' do it { is_expected.to run.with_params('one', 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } - it { is_expected.to run.with_params(%w[12345678 two], 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } + it { is_expected.to run.with_params(['12345678', 'two'], 10, 5).and_raise_error(Puppet::ParseError, %r{Expected length}) } end describe 'accepts strings of length between and including the limits' do @@ -56,7 +56,7 @@ it { is_expected.to run.with_params('12345678', 10, 5) } it { is_expected.to run.with_params('123456789', 10, 5) } it { is_expected.to run.with_params('1234567890', 10, 5) } - it { is_expected.to run.with_params(%w[1233456 12345678], 10, 5) } + it { is_expected.to run.with_params(['1233456', '12345678'], 10, 5) } end end diff --git a/spec/functions/values_at_spec.rb b/spec/functions/values_at_spec.rb index c405423b7..048f270b1 100644 --- a/spec/functions/values_at_spec.rb +++ b/spec/functions/values_at_spec.rb @@ -31,8 +31,8 @@ end context 'when requesting a single item using UTF8 and double byte characters' do - it { is_expected.to run.with_params(%w[ẩ β с ď], 0).and_return(['ẩ']) } - it { is_expected.to run.with_params(%w[文 字 の 値], 2).and_return(['の']) } + 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 diff --git a/spec/functions/values_spec.rb b/spec/functions/values_spec.rb index 85554c6ac..850d31472 100644 --- a/spec/functions/values_spec.rb +++ b/spec/functions/values_spec.rb @@ -14,7 +14,7 @@ it { is_expected.to run.with_params('key' => 'value').and_return(['value']) } it 'returns the array of values' do result = subject.call([{ 'key1' => 'value1', 'key2' => 'value2', 'duplicate_value_key' => 'value2' }]) - expect(result).to match_array(%w[value1 value2 value2]) + expect(result).to match_array(['value1', 'value2', 'value2']) end it 'runs with UTF8 and double byte characters' do diff --git a/spec/functions/zip_spec.rb b/spec/functions/zip_spec.rb index 2cc8c0cd1..433e44800 100644 --- a/spec/functions/zip_spec.rb +++ b/spec/functions/zip_spec.rb @@ -14,7 +14,7 @@ it { is_expected.to run.with_params([1, 2, 3], [4, 5, 6], true).and_return([1, 4, 2, 5, 3, 6]) } context 'with UTF8 and double byte characters' do - it { is_expected.to run.with_params(%w[ầ ь ć], %w[đ ề ƒ]).and_return([%w[ầ đ], %w[ь ề], %w[ć ƒ]]) } - it { is_expected.to run.with_params(%w[ペ 含 値], %w[ッ 文 イ]).and_return([%w[ペ ッ], %w[含 文], %w[値 イ]]) } + 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.rb b/spec/spec_helper.rb index efd225b54..e11719268 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' @@ -27,4 +28,9 @@ RSpec.configure do |c| c.default_facts = default_facts + c.before :each do + # set to strictest setting for testing + # by default Puppet runs at warning level + Puppet.settings[:strict] = :warning + end end diff --git a/spec/type_aliases/absolute_path_spec.rb b/spec/type_aliases/absolute_path_spec.rb index 55a68624a..cb8df6c7b 100644 --- a/spec/type_aliases/absolute_path_spec.rb +++ b/spec/type_aliases/absolute_path_spec.rb @@ -3,22 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Compat::Absolute_path' do describe 'valid paths handling' do - %w[ - C:/ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - //host/windows - / - /var/tmp - /var/opt/../lib/puppet - /var/opt//lib/puppet - /var/ůťƒ8 - /var/ネット - ].each do |value| + ['C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/', '/var/tmp', '/var/opt/../lib/puppet', '/var/opt//lib/puppet', '/var/ůťƒ8', '/var/ネット'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end @@ -42,18 +27,7 @@ end context 'with relative paths' do - %w[ - relative1 - . - .. - ./foo - ../foo - etc/puppetlabs/puppet - opt/puppet/bin - relative\\windows - \var\ůťƒ8 - \var\ネット - ].each do |value| + ['relative1', '.', '..', './foo', '../foo', 'etc/puppetlabs/puppet', 'opt/puppet/bin', 'relative\\windows', '\\var\\ůťƒ8', '\\var\\ネット'].each do |value| describe value.inspect do it { is_expected.not_to allow_value(value) } end diff --git a/spec/type_aliases/base32_spec.rb b/spec/type_aliases/base32_spec.rb index 7e0076f57..b78739122 100644 --- a/spec/type_aliases/base32_spec.rb +++ b/spec/type_aliases/base32_spec.rb @@ -3,22 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Base32' do describe 'valid handling' do - %w[ - ASDASDDASD3453453 - ASDASDDASD3453453= - ASDASDDASD3453453== - ASDASDDASD3453453=== - ASDASDDASD3453453==== - ASDASDDASD3453453===== - ASDASDDASD3453453====== - asdasddasd3453453 - asdasddasd3453453= - asdasddasd3453453== - asdasddasd3453453=== - asdasddasd3453453==== - asdasddasd3453453===== - asdasddasd3453453====== - ].each do |value| + ['ASDASDDASD3453453', 'ASDASDDASD3453453=', 'ASDASDDASD3453453==', 'ASDASDDASD3453453===', 'ASDASDDASD3453453====', 'ASDASDDASD3453453=====', 'ASDASDDASD3453453======', 'asdasddasd3453453', 'asdasddasd3453453=', 'asdasddasd3453453==', 'asdasddasd3453453===', 'asdasddasd3453453====', 'asdasddasd3453453=====', 'asdasddasd3453453======'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/base64_spec.rb b/spec/type_aliases/base64_spec.rb index 1c5391610..33d599d2e 100644 --- a/spec/type_aliases/base64_spec.rb +++ b/spec/type_aliases/base64_spec.rb @@ -3,11 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Base64' do describe 'valid handling' do - %w[ - asdasdASDSADA342386832/746+= - asdasdASDSADA34238683274/6+ - asdasdASDSADA3423868327/46+== - ].each do |value| + ['asdasdASDSADA342386832/746+=', 'asdasdASDSADA34238683274/6+', 'asdasdASDSADA3423868327/46+=='].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/filemode_spec.rb b/spec/type_aliases/filemode_spec.rb index 282f74aae..b6d85cc8a 100644 --- a/spec/type_aliases/filemode_spec.rb +++ b/spec/type_aliases/filemode_spec.rb @@ -3,14 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Filemode' do describe 'valid modes' do - %w[ - 0644 - 1644 - 2644 - 4644 - 0123 - 0777 - ].each do |value| + ['0644', '1644', '2644', '4644', '0123', '0777'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/filesource_spec.rb b/spec/type_aliases/filesource_spec.rb index da1bc3e55..47e328a9a 100644 --- a/spec/type_aliases/filesource_spec.rb +++ b/spec/type_aliases/filesource_spec.rb @@ -3,29 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Filesource' do describe 'valid handling' do - %w[ - https://hello.com - https://notcreative.org - https://canstillaccepthttps.co.uk - http://anhttp.com - http://runningoutofideas.gov - file:///hello/bla - file:///foo/bar.log - puppet:///modules/foo/bar.log - puppet://pm.example.com/modules/foo/bar.log - puppet://192.0.2.1/modules/foo/bar.log - /usr2/username/bin:/usr/local/bin:/usr/bin:. - C:/ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - //host/windows - /var/tmp - /var/opt/../lib/puppet - ].each do |value| + ['https://hello.com', 'https://notcreative.org', 'https://canstillaccepthttps.co.uk', 'http://anhttp.com', 'http://runningoutofideas.gov', 'file:///hello/bla', 'file:///foo/bar.log', 'puppet:///modules/foo/bar.log', 'puppet://pm.example.com/modules/foo/bar.log', 'puppet://192.0.2.1/modules/foo/bar.log', '/usr2/username/bin:/usr/local/bin:/usr/bin:.', 'C:/', 'C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', '//host/windows', '/var/tmp', '/var/opt/../lib/puppet'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/fqdn_spec.rb b/spec/type_aliases/fqdn_spec.rb index e50aab107..fcfb980ee 100644 --- a/spec/type_aliases/fqdn_spec.rb +++ b/spec/type_aliases/fqdn_spec.rb @@ -3,11 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Fqdn' do describe 'valid handling' do - %w[ - example - example.com - www.example.com - ].each do |value| + ['example', 'example.com', 'www.example.com'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/host_spec.rb b/spec/type_aliases/host_spec.rb index a85e0ee7c..e287a74d6 100644 --- a/spec/type_aliases/host_spec.rb +++ b/spec/type_aliases/host_spec.rb @@ -3,18 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Host' do describe 'valid handling' do - %w[ - example - example.com - www.example.com - 2001:0db8:85a3:0000:0000:8a2e:0370:7334 - fa76:8765:34ac:0823:ab76:eee9:0987:1111 - 2001:0db8::1 - 224.0.0.0 - 255.255.255.255 - 0.0.0.0 - 192.88.99.0 - ].each do |value| + ['example', 'example.com', 'www.example.com', '2001:0db8:85a3:0000:0000:8a2e:0370:7334', 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', '2001:0db8::1', '224.0.0.0', '255.255.255.255', '0.0.0.0', '192.88.99.0'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/httpsurl_spec.rb b/spec/type_aliases/httpsurl_spec.rb index dd958758a..1a43c0a1d 100644 --- a/spec/type_aliases/httpsurl_spec.rb +++ b/spec/type_aliases/httpsurl_spec.rb @@ -3,13 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::HTTPSUrl' do describe 'valid handling' do - %w[ - https://hello.com - https://notcreative.org - https://notexciting.co.uk - https://graphemica.com/❤ - https://graphemica.com/緩 - ].each do |value| + ['https://hello.com', 'https://notcreative.org', 'https://notexciting.co.uk', 'https://graphemica.com/❤', 'https://graphemica.com/緩'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/httpurl_spec.rb b/spec/type_aliases/httpurl_spec.rb index 6684e24b3..5f076fde7 100644 --- a/spec/type_aliases/httpurl_spec.rb +++ b/spec/type_aliases/httpurl_spec.rb @@ -3,16 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::HTTPUrl' do describe 'valid handling' do - %w[ - https://hello.com - https://notcreative.org - https://canstillaccepthttps.co.uk - http://anhttp.com - http://runningoutofideas.gov - http:// - http://graphemica.com/❤ - http://graphemica.com/緩 - ].each do |value| + ['https://hello.com', 'https://notcreative.org', 'https://canstillaccepthttps.co.uk', 'http://anhttp.com', 'http://runningoutofideas.gov', 'http://', 'http://graphemica.com/❤', 'http://graphemica.com/緩'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/unixpath_spec.rb b/spec/type_aliases/unixpath_spec.rb index 3d9e95c0e..c31a3a6fe 100644 --- a/spec/type_aliases/unixpath_spec.rb +++ b/spec/type_aliases/unixpath_spec.rb @@ -3,15 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Unixpath' do describe 'valid handling' do - %w[ - /usr2/username/bin:/usr/local/bin:/usr/bin:. - /var/tmp - /Users/helencampbell/workspace/puppetlabs-stdlib - /var/ůťƒ8 - /var/ネット - /var//tmp - /var/../tmp - ].each do |value| + ['/usr2/username/bin:/usr/local/bin:/usr/bin:.', '/var/tmp', '/Users/helencampbell/workspace/puppetlabs-stdlib', '/var/ůťƒ8', '/var/ネット', '/var//tmp', '/var/../tmp'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/type_aliases/windowspath_spec.rb b/spec/type_aliases/windowspath_spec.rb index fdf2dc4db..4edc430ba 100644 --- a/spec/type_aliases/windowspath_spec.rb +++ b/spec/type_aliases/windowspath_spec.rb @@ -3,16 +3,7 @@ if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 describe 'Stdlib::Windowspath' do describe 'valid handling' do - %w[ - C:\\ - C:\\WINDOWS\\System32 - C:/windows/system32 - X:/foo/bar - X:\\foo\\bar - \\\\host\\windows - X:/var/ůťƒ8 - X:/var/ネット - ].each do |value| + ['C:\\', 'C:\\WINDOWS\\System32', 'C:/windows/system32', 'X:/foo/bar', 'X:\\foo\\bar', '\\\\host\\windows', 'X:/var/ůťƒ8', 'X:/var/ネット'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end diff --git a/spec/unit/facter/pe_version_spec.rb b/spec/unit/facter/pe_version_spec.rb index 73c4bfd8d..46d89bcfa 100644 --- a/spec/unit/facter/pe_version_spec.rb +++ b/spec/unit/facter/pe_version_spec.rb @@ -28,7 +28,7 @@ end context 'when PE is installed' do - %w[2.6.1 2.10.300].each do |version| + ['2.6.1', '2.10.300'].each do |version| puppetversion = "2.7.19 (Puppet Enterprise #{version})" context "puppetversion => #{puppetversion}" do before :each do diff --git a/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb b/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb index c2a237ead..39d3b7afb 100644 --- a/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb +++ b/spec/unit/puppet/parser/functions/enclose_ipv6_spec.rb @@ -12,7 +12,7 @@ end it 'raises a ParseError if there is more than 1 arguments' do - expect { scope.function_enclose_ipv6(%w[argument1 argument2]) }.to(raise_error(Puppet::ParseError)) + expect { scope.function_enclose_ipv6(['argument1', 'argument2']) }.to(raise_error(Puppet::ParseError)) end it 'raises a ParseError when given garbage' do