summaryrefslogtreecommitdiff
path: root/code/environments/production/modules/stdlib/spec/acceptance
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-09-20 14:49:52 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2018-09-20 14:49:52 +0200
commit774cf89157a6c5af2566d98607a8b9aa655e33b0 (patch)
treecc7a73cb9e941b0338771653bdc301c80f2e61c7 /code/environments/production/modules/stdlib/spec/acceptance
parent9513b93a992470e21e387db1451fa4fd21ffc5d6 (diff)
downloadpuppet.DEV-774cf89157a6c5af2566d98607a8b9aa655e33b0.tar.gz
puppet.DEV-774cf89157a6c5af2566d98607a8b9aa655e33b0.tar.bz2
puppet.DEV-774cf89157a6c5af2566d98607a8b9aa655e33b0.zip
Bundle puppetlabs-stdlib 4.25.1.
Diffstat (limited to 'code/environments/production/modules/stdlib/spec/acceptance')
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/abs_spec.rb27
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/anchor_spec.rb25
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/any2array_spec.rb45
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/base64_spec.rb16
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/bool2num_spec.rb31
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/build_csv.rb89
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/capitalize_spec.rb30
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/ceiling_spec.rb37
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/chomp_spec.rb19
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/chop_spec.rb41
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/clamp_spec.rb38
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/concat_spec.rb52
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/count_spec.rb27
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/deep_merge_spec.rb18
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/defined_with_params_spec.rb20
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/delete_at_spec.rb17
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/delete_spec.rb17
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb17
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/delete_values_spec.rb23
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/deprecation_spec.rb92
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/difference_spec.rb24
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/dirname_spec.rb39
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/downcase_spec.rb37
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/empty_spec.rb51
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/ensure_resource_spec.rb29
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/flatten_spec.rb37
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/floor_spec.rb37
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb64
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb62
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/get_module_path_spec.rb25
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/getparam_spec.rb22
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/getvar_spec.rb24
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/grep_spec.rb24
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/has_interface_with_spec.rb52
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/has_ip_address_spec.rb31
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/has_ip_network_spec.rb31
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/has_key_spec.rb39
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/hash_spec.rb24
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/intersection_spec.rb25
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_a_spec.rb27
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_array_spec.rb65
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_bool_spec.rb79
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_domain_name_spec.rb81
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_float_spec.rb84
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_function_available_spec.rb56
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_hash_spec.rb61
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_integer_spec.rb93
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_ip_address_spec.rb78
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb50
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb64
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_mac_address_spec.rb36
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_numeric_spec.rb93
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/is_string_spec.rb111
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb22
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/join_spec.rb24
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/keys_spec.rb21
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/loadjson_spec.rb48
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/loadyaml_spec.rb52
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/lstrip_spec.rb32
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/max_spec.rb18
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/member_spec.rb57
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/merge_spec.rb22
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/min_spec.rb18
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml10
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml10
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/nodesets/default.yml10
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml12
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml11
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml12
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/num2bool_spec.rb76
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/parsejson_spec.rb50
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/parseyaml_spec.rb52
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/pick_default_spec.rb51
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/pick_spec.rb42
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/prefix_spec.rb40
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/pw_hash_spec.rb31
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/range_spec.rb34
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/reject_spec.rb40
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/reverse_spec.rb21
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/rstrip_spec.rb32
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/shuffle_spec.rb32
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/size_spec.rb53
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/sort_spec.rb32
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/squeeze_spec.rb44
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/str2bool_spec.rb29
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb20
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/strftime_spec.rb20
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/strip_spec.rb32
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/suffix_spec.rb40
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/swapcase_spec.rb20
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/time_spec.rb32
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/to_bytes_spec.rb25
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/try_get_value_spec.rb44
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/type3x_spec.rb27
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/type_spec.rb35
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/union_spec.rb23
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/unique_spec.rb31
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/upcase_spec.rb31
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/uriescape_spec.rb21
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb29
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_array_spec.rb35
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_augeas_spec.rb61
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_bool_spec.rb35
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_cmd_spec.rb50
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_hash_spec.rb36
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb29
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb29
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_re_spec.rb46
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_slength_spec.rb70
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/validate_string_spec.rb42
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/values_at_spec.rb71
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/values_spec.rb29
-rw-r--r--code/environments/production/modules/stdlib/spec/acceptance/zip_spec.rb71
113 files changed, 4408 insertions, 0 deletions
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/abs_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/abs_spec.rb
new file mode 100644
index 0000000..78d790f
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/abs_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper_acceptance'
+
+describe 'abs function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $input = '-34.56'
+ $output = abs($input)
+ notify { "$output": }
+ DOC
+ it 'accepts a string' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: 34.56})
+ end
+ end
+
+ pp2 = <<-DOC
+ $input = -35.46
+ $output = abs($input)
+ notify { "$output": }
+ DOC
+ it 'accepts a float' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: 35.46})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/anchor_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/anchor_spec.rb
new file mode 100644
index 0000000..3cf0c92
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/anchor_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper_acceptance'
+
+describe 'anchor type' do
+ describe 'success' do
+ pp = <<-DOC
+ class anchored {
+ anchor { 'anchored::begin': }
+ ~> anchor { 'anchored::end': }
+ }
+
+ class anchorrefresh {
+ notify { 'first': }
+ ~> class { 'anchored': }
+ ~> anchor { 'final': }
+ }
+
+ include anchorrefresh
+ DOC
+ it 'effects proper chaining of resources' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Anchor\[final\]: Triggered 'refresh'})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/any2array_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/any2array_spec.rb
new file mode 100644
index 0000000..2f1ae4e
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/any2array_spec.rb
@@ -0,0 +1,45 @@
+require 'spec_helper_acceptance'
+
+describe 'any2array function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $input = ''
+ $output = any2array($input)
+ validate_array($output)
+ notify { "Output: ${output}": }
+ DOC
+ it 'creates an empty array' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: Output: })
+ end
+ end
+
+ pp2 = <<-DOC
+ $input = ['array', 'test']
+ $output = any2array($input)
+ validate_array($output)
+ notify { "Output: ${output}": }
+ DOC
+ it 'leaves arrays modified' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: Output: (\[|)array(,\s|)test(\]|)})
+ end
+ end
+
+ pp3 = <<-DOC
+ $input = {'test' => 'array'}
+ $output = any2array($input)
+
+ validate_array($output)
+ # Check each element of the array is a plain string.
+ validate_string($output[0])
+ validate_string($output[1])
+ notify { "Output: ${output}": }
+ DOC
+ it 'turns a hash into an array' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: Output: (\[|)test(,\s|)array(\]|)})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/base64_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/base64_spec.rb
new file mode 100644
index 0000000..5cc4d62
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/base64_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper_acceptance'
+
+describe 'base64 function' do
+ describe 'success' do
+ pp = <<-DOC
+ $encodestring = base64('encode', 'thestring')
+ $decodestring = base64('decode', $encodestring)
+ notify { $decodestring: }
+ DOC
+ it 'encodes then decode a string' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{thestring})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/bool2num_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/bool2num_spec.rb
new file mode 100644
index 0000000..2a62435
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/bool2num_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper_acceptance'
+
+describe 'bool2num function' do
+ describe 'success' do
+ %w[false f 0 n no].each do |bool|
+ pp1 = <<-DOC
+ $input = "#{bool}"
+ $output = bool2num($input)
+ notify { "$output": }
+ DOC
+ it "should convert a given boolean, #{bool}, to 0" do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: 0})
+ end
+ end
+ end
+
+ %w[true t 1 y yes].each do |bool|
+ pp2 = <<-DOC
+ $input = "#{bool}"
+ $output = bool2num($input)
+ notify { "$output": }
+ DOC
+ it "should convert a given boolean, #{bool}, to 1" do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: 1})
+ end
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/build_csv.rb b/code/environments/production/modules/stdlib/spec/acceptance/build_csv.rb
new file mode 100644
index 0000000..9059858
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/build_csv.rb
@@ -0,0 +1,89 @@
+# vim: set sw=2 sts=2 et tw=80 :
+require 'rspec'
+
+# XXX Super ugly hack to keep from starting beaker nodes
+module Kernel
+ # make an alias of the original require
+ alias original_require require
+ # rewrite require
+ def require(name)
+ original_require name if name != 'spec_helper_acceptance'
+ end
+end
+UNSUPPORTED_PLATFORMS = [].freeze
+def fact(*_args)
+ []
+end
+# XXX End hax
+
+# Get a list of functions for test coverage
+function_list = Dir[File.join(File.dirname(__FILE__), '..', '..', 'lib', 'puppet', 'parser', 'functions', '*.rb')].map do |function_rb|
+ File.basename(function_rb, '.rb')
+end
+
+## Configure rspec to parse tests
+options = RSpec::Core::ConfigurationOptions.new(['spec/acceptance'])
+configuration = RSpec.configuration
+world = RSpec.world
+options.parse_options
+options.configure(configuration)
+configuration.load_spec_files
+
+## Collect up tests and example groups into a hash
+def get_tests(children)
+ children.each_with_object({}) do |c, memo|
+ memo[c.description] = {}
+ memo[c.description]['groups'] = get_tests(c.children) unless c.children.empty?
+ unless c.examples.empty?
+ memo[c.description]['tests'] = c.examples.map { |e|
+ e.description unless e.pending?
+ }.compact
+ end
+ next if c.examples.empty?
+ memo[c.description]['pending_tests'] = c.examples.map { |e|
+ e.description if e.pending?
+ }.compact
+ end
+end
+
+def count_test_types_in(type, group)
+ return 0 if group.nil?
+ group.reduce(0) do |m, (k, v)|
+ m += v.length if k == type
+ m += count_tests_in(v) if v.is_a?(Hash)
+ m
+ end
+end
+
+def count_tests_in(group)
+ count_test_types_in('tests', group)
+end
+
+def count_pending_tests_in(group)
+ count_test_types_in('pending_tests', group)
+end
+
+# Convert tests hash to csv format
+def to_csv(function_list, tests)
+ function_list.map { |function_name|
+ v = tests["#{function_name} function"]
+ if v
+ positive_tests = count_tests_in(v['groups']['success'])
+ negative_tests = count_tests_in(v['groups']['failure'])
+ pending_tests =
+ count_pending_tests_in(v['groups']['failure']) +
+ count_pending_tests_in(v['groups']['failure'])
+ else
+ positive_tests = 0
+ negative_tests = 0
+ pending_tests = 0
+ end
+ '%-25s, %-9d, %-9d, %-9d' % [function_name, positive_tests, negative_tests, pending_tests]
+ }.compact
+end
+
+tests = get_tests(world.example_groups)
+csv = to_csv(function_list, tests)
+percentage_tested = "#{tests.count * 100 / function_list.count}%"
+printf("%-25s, %-9s, %-9s, %-9s\n", "#{percentage_tested} have tests.", 'Positive', 'Negative', 'Pending')
+puts csv
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/capitalize_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/capitalize_spec.rb
new file mode 100644
index 0000000..ce75645
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/capitalize_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper_acceptance'
+
+describe 'capitalize function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $input = 'this is a string'
+ $output = capitalize($input)
+ notify { $output: }
+ DOC
+ it 'capitalizes the first letter of a string' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: This is a string})
+ end
+ end
+
+ pp2 = <<-DOC
+ $input = ['this', 'is', 'a', 'string']
+ $output = capitalize($input)
+ notify { $output: }
+ DOC
+ regex_array = [%r{Notice: This}, %r{Notice: Is}, %r{Notice: A}, %r{Notice: String}]
+ it 'capitalizes the first letter of an array of strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ regex_array.each do |i|
+ expect(r.stdout).to match(i)
+ end
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/ceiling_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/ceiling_spec.rb
new file mode 100644
index 0000000..3f686d2
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/ceiling_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper_acceptance'
+
+describe 'ceiling function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = 12.8
+ $b = 13
+ $o = ceiling($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'ceilings floats' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = 7
+ $b = 7
+ $o = ceiling($a)
+ if $o == $b {
+ notify { 'output is correct': }
+ }
+ DOC
+ it 'ceilings integers' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output is correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/chomp_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/chomp_spec.rb
new file mode 100644
index 0000000..ba5e7cb
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/chomp_spec.rb
@@ -0,0 +1,19 @@
+require 'spec_helper_acceptance'
+
+describe 'chomp function' do
+ describe 'success' do
+ pp = <<-DOC
+ $input = "test\n"
+ if size($input) != 5 {
+ fail("Size of ${input} is not 5.")
+ }
+ $output = chomp($input)
+ if size($output) != 4 {
+ fail("Size of ${input} is not 4.")
+ }
+ DOC
+ it 'eats the newline' do
+ apply_manifest(pp, :catch_failures => true)
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/chop_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/chop_spec.rb
new file mode 100644
index 0000000..6489c28
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/chop_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper_acceptance'
+
+describe 'chop function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $input = "test"
+ if size($input) != 4 {
+ fail("Size of ${input} is not 4.")
+ }
+ $output = chop($input)
+ if size($output) != 3 {
+ fail("Size of ${input} is not 3.")
+ }
+ DOC
+ it 'eats the last character' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-'DOC'
+ $input = "test\r\n"
+ if size($input) != 6 {
+ fail("Size of ${input} is not 6.")
+ }
+ $output = chop($input)
+ if size($output) != 4 {
+ fail("Size of ${input} is not 4.")
+ }
+ DOC
+ it 'eats the last two characters of \r\n' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+
+ pp3 = <<-DOC
+ $input = ""
+ $output = chop($input)
+ DOC
+ it 'does not fail on empty strings' do
+ apply_manifest(pp3, :catch_failures => true)
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/clamp_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/clamp_spec.rb
new file mode 100644
index 0000000..9885f56
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/clamp_spec.rb
@@ -0,0 +1,38 @@
+require 'spec_helper_acceptance'
+
+describe 'clamp function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $x = 17
+ $y = 225
+ $z = 155
+ $o = clamp($x, $y, $z)
+ if $o == $z {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'clamps list of values' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = [7, 19, 66]
+ $b = 19
+ $o = clamp($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'clamps array of values' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/concat_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/concat_spec.rb
new file mode 100644
index 0000000..391b848
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/concat_spec.rb
@@ -0,0 +1,52 @@
+require 'spec_helper_acceptance'
+
+describe 'concat function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $output = concat(['1','2','3'],['4','5','6'])
+ validate_array($output)
+ if size($output) != 6 {
+ fail("${output} should have 6 elements.")
+ }
+ DOC
+ it 'concats one array to another' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $output = concat(['1','2','3'],'4','5','6',['7','8','9'])
+ validate_array($output)
+ if size($output) != 9 {
+ fail("${output} should have 9 elements.")
+ }
+ DOC
+ it 'concats arrays and primitives to array' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+
+ pp3 = <<-DOC
+ $output = concat(['1','2','3'],['4','5','6'],['7','8','9'])
+ validate_array($output)
+ if size($output) != 9 {
+ fail("${output} should have 9 elements.")
+ }
+ DOC
+ it 'concats multiple arrays to one' do
+ apply_manifest(pp3, :catch_failures => true)
+ end
+
+ pp4 = <<-DOC
+ $output = concat([{"a" => "b"}], {"c" => "d", "e" => "f"})
+ validate_array($output)
+ if size($output) != 2 {
+ fail("${output} should have 2 elements.")
+ }
+ if $output[1] != {"c" => "d", "e" => "f"} {
+ fail("${output} does not have the expected hash for the second element.")
+ }
+ DOC
+ it 'concats hash arguments' do
+ apply_manifest(pp4, :catch_failures => true)
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/count_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/count_spec.rb
new file mode 100644
index 0000000..c134836
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/count_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper_acceptance'
+
+describe 'count function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $input = [1,2,3,4]
+ $output = count($input)
+ notify { "$output": }
+ DOC
+ it 'counts elements in an array' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: 4})
+ end
+ end
+
+ pp2 = <<-DOC
+ $input = [1,1,1,2]
+ $output = count($input, 1)
+ notify { "$output": }
+ DOC
+ it 'counts elements in an array that match a second argument' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: 3})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/deep_merge_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/deep_merge_spec.rb
new file mode 100644
index 0000000..29a2c79
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/deep_merge_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper_acceptance'
+
+describe 'deep_merge function' do
+ describe 'success' do
+ pp = <<-DOC
+ $hash1 = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
+ $hash2 = {'two' => 'dos', 'three' => { 'five' => 5 } }
+ $merged_hash = deep_merge($hash1, $hash2)
+
+ if $merged_hash != { 'one' => 1, 'two' => 'dos', 'three' => { 'four' => 4, 'five' => 5 } } {
+ fail("Hash was incorrectly merged.")
+ }
+ DOC
+ it 'deeps merge two hashes' do
+ apply_manifest(pp, :catch_failures => true)
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/defined_with_params_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/defined_with_params_spec.rb
new file mode 100644
index 0000000..b12927a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/defined_with_params_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper_acceptance'
+
+describe 'defined_with_params function' do
+ describe 'success' do
+ pp = <<-DOC
+ user { 'dan':
+ ensure => present,
+ }
+
+ if defined_with_params(User[dan], {'ensure' => 'present' }) {
+ notify { 'User defined with ensure=>present': }
+ }
+ DOC
+ it 'successfullies notify' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: User defined with ensure=>present})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/delete_at_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/delete_at_spec.rb
new file mode 100644
index 0000000..6a34e21
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/delete_at_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper_acceptance'
+
+describe 'delete_at function' do
+ describe 'success' do
+ pp = <<-DOC
+ $output = delete_at(['a','b','c','b'], 1)
+ if $output == ['a','c','b'] {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'deletes elements of the array' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/delete_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/delete_spec.rb
new file mode 100644
index 0000000..70877cb
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/delete_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper_acceptance'
+
+describe 'delete function' do
+ pp = <<-DOC
+ $output = delete(['a','b','c','b'], 'b')
+ if $output == ['a','c'] {
+ notify { 'output correct': }
+ }
+ DOC
+ describe 'success' do
+ it 'deletes elements of the array' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb
new file mode 100644
index 0000000..418c959
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/delete_undef_values_spec.rb
@@ -0,0 +1,17 @@
+require 'spec_helper_acceptance'
+
+describe 'delete_undef_values function' do
+ describe 'success' do
+ pp = <<-DOC
+ $output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
+ if $output == { a => 'A', b => '', d => false } {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'deletes elements of the array' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/delete_values_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/delete_values_spec.rb
new file mode 100644
index 0000000..634d319
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/delete_values_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper_acceptance'
+
+describe 'delete_values function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' }
+ $b = { 'a' => 'A', 'B' => 'C' }
+ $o = delete_values($a, 'B')
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'deletes elements of the hash' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles non-hash arguments'
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/deprecation_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/deprecation_spec.rb
new file mode 100644
index 0000000..9f25449
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/deprecation_spec.rb
@@ -0,0 +1,92 @@
+require 'spec_helper_acceptance'
+
+describe 'deprecation function' do
+ test_file = if fact('operatingsystem') == 'windows'
+ 'C:/deprecation'
+ else
+ '/tmp/deprecation'
+ end
+
+ # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
+ add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
+ remove_file_manifest = "file { '#{test_file}': ensure => absent }"
+
+ before :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ context 'with --strict=error', :if => return_puppet_version =~ %r{^4} do
+ let(:result) { on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it 'returns an error' do
+ expect(result.exit_code).to eq(1)
+ end
+
+ it 'shows the error message' do
+ expect(result.stderr).to match(%r{deprecation. key. message})
+ end
+
+ describe file(test_file.to_s) do
+ it { is_expected.not_to be_file }
+ end
+ end
+
+ context 'with --strict=warning', :if => return_puppet_version =~ %r{^4} do
+ let(:result) { on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it 'does not return an error' do
+ expect(result.exit_code).to eq(0)
+ end
+
+ it 'shows the error message' do
+ expect(result.stderr).to match(%r{Warning: message})
+ end
+
+ describe file(test_file.to_s) do
+ it { is_expected.to be_file }
+ end
+ end
+
+ context 'with --strict=off', :if => return_puppet_version =~ %r{^4} do
+ let(:result) { on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it 'does not return an error' do
+ expect(result.exit_code).to eq(0)
+ end
+
+ it 'does not show the error message' do
+ expect(result.stderr).not_to match(%r{Warning: message})
+ end
+
+ describe file(test_file.to_s) do
+ it { is_expected.to be_file }
+ end
+ end
+
+ context 'puppet 3 test', :if => return_puppet_version =~ %r{^3} do
+ let(:result) { on(default, puppet('apply', '--parser=future', '-e', add_file_manifest), :acceptable_exit_codes => (0...256)) }
+
+ after :all do
+ apply_manifest(remove_file_manifest)
+ end
+
+ it 'returns a deprecation error' do
+ expect(result.stderr).to match(%r{Warning: message})
+ end
+ it 'passes without error' do
+ expect(result.exit_code).to eq(0)
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/difference_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/difference_spec.rb
new file mode 100644
index 0000000..7988f69
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/difference_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper_acceptance'
+
+describe 'difference function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ['a','b','c']
+ $b = ['b','c','d']
+ $c = ['a']
+ $o = difference($a, $b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'returns non-duplicates in the first array' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles non-array arguments'
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/dirname_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/dirname_spec.rb
new file mode 100644
index 0000000..a532e11
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/dirname_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper_acceptance'
+
+describe 'dirname function' do
+ describe 'success' do
+ context 'with absolute path' do
+ pp1 = <<-DOC
+ $a = '/path/to/a/file.txt'
+ $b = '/path/to/a'
+ $o = dirname($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'returns the dirname' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ context 'with relative path' do
+ pp2 = <<-DOC
+ $a = 'path/to/a/file.txt'
+ $b = 'path/to/a'
+ $o = dirname($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'returns the dirname' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/downcase_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/downcase_spec.rb
new file mode 100644
index 0000000..2ff55f4
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/downcase_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper_acceptance'
+
+describe 'downcase function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = 'AOEU'
+ $b = 'aoeu'
+ $o = downcase($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'returns the downcase' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = 'aoeu aoeu'
+ $b = 'aoeu aoeu'
+ $o = downcase($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'doesn\'t affect lowercase words' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/empty_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/empty_spec.rb
new file mode 100644
index 0000000..c5c63c0
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/empty_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper_acceptance'
+
+describe 'empty function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ''
+ $b = true
+ $o = empty($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'recognizes empty strings' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = 'aoeu'
+ $b = false
+ $o = empty($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'recognizes non-empty strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = 7
+ $b = false
+ $o = empty($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'handles numerical values' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/ensure_resource_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/ensure_resource_spec.rb
new file mode 100644
index 0000000..21e73d3
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/ensure_resource_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper_acceptance'
+
+describe 'ensure_resource function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ notify { "test": loglevel => 'err' }
+ ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+ DOC
+ it 'ensures a resource already declared' do
+ apply_manifest('')
+
+ apply_manifest(pp1, :expect_changes => true)
+ end
+
+ pp2 = <<-DOC
+ ensure_resource('notify', 'test', { 'loglevel' => 'err' })
+ DOC
+ it 'ensures a undeclared resource' do
+ apply_manifest('')
+
+ apply_manifest(pp2, :expect_changes => true)
+ end
+ it 'takes defaults arguments'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/flatten_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/flatten_spec.rb
new file mode 100644
index 0000000..79d4854
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/flatten_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper_acceptance'
+
+describe 'flatten function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ["a","b",["c",["d","e"],"f","g"]]
+ $b = ["a","b","c","d","e","f","g"]
+ $o = flatten($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'flattens arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = ["a","b","c","d","e","f","g"]
+ $b = ["a","b","c","d","e","f","g"]
+ $o = flatten($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'does not affect flat arrays' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/floor_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/floor_spec.rb
new file mode 100644
index 0000000..312eec3
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/floor_spec.rb
@@ -0,0 +1,37 @@
+require 'spec_helper_acceptance'
+
+describe 'floor function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = 12.8
+ $b = 12
+ $o = floor($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'floors floats' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = 7
+ $b = 7
+ $o = floor($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'floors integers' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb
new file mode 100644
index 0000000..5916553
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/fqdn_rand_string_spec.rb
@@ -0,0 +1,64 @@
+require 'spec_helper_acceptance'
+
+describe 'fqdn_rand_string function' do
+ describe 'success' do
+ include_context 'with faked facts'
+ context "when the FQDN is 'fakehost.localdomain'" do
+ before :each do
+ fake_fact('fqdn', 'fakehost.localdomain')
+ end
+
+ pp1 = <<-PUPPETCODE
+ $l = 10
+ $o = fqdn_rand_string($l)
+ notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+ PUPPETCODE
+ it 'generates random alphanumeric strings' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rand_string is "(7oDp0KOr1b|9Acvnhkt4J)"})
+ end
+ end
+
+ pp2 = <<-PUPPETCODE
+ $l = 10
+ $c = '0123456789'
+ $o = fqdn_rand_string($l, $c)
+ notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+ PUPPETCODE
+ it 'generates random alphanumeric strings with custom charsets' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rand_string is "(7203048515|2383756694)"})
+ end
+ end
+
+ pp3 = <<-PUPPETCODE
+ $l = 10
+ $s = 'seed'
+ $o = fqdn_rand_string($l, undef, $s)
+ notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+ PUPPETCODE
+ it 'generates random alphanumeric strings with custom seeds' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rand_string is "(3HS4mbuI3E|1jJtAMs94d)"})
+ end
+ end
+
+ pp4 = <<-PUPPETCODE
+ $l = 10
+ $c = '0123456789'
+ $s = 'seed'
+ $o = fqdn_rand_string($l, $c, $s)
+ notice(inline_template('fqdn_rand_string is <%= @o.inspect %>'))
+ PUPPETCODE
+ it 'generates random alphanumeric strings with custom charsets and seeds' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rand_string is "(3104058232|7100592312)"})
+ end
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers for length argument'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb
new file mode 100644
index 0000000..99f315e
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb
@@ -0,0 +1,62 @@
+require 'spec_helper_acceptance'
+
+describe 'fqdn_rotate function' do
+ describe 'success' do
+ include_context 'with faked facts'
+ context "when the FQDN is 'fakehost.localdomain'" do
+ before :each do
+ fake_fact('fqdn', 'fakehost.localdomain')
+ end
+
+ pp1 = <<-DOC
+ $a = ['a','b','c','d']
+ $o = fqdn_rotate($a)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ DOC
+ it 'rotates arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rotate is \["d", "a", "b", "c"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = ['a','b','c','d']
+ $s = 'seed'
+ $o = fqdn_rotate($a, $s)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ DOC
+ it 'rotates arrays with custom seeds' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rotate is \["c", "d", "a", "b"\]})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = 'abcd'
+ $o = fqdn_rotate($a)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ DOC
+ it 'rotates strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rotate is "dabc"})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = 'abcd'
+ $s = 'seed'
+ $o = fqdn_rotate($a, $s)
+ notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
+ DOC
+ it 'rotates strings with custom seeds' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{fqdn_rotate is "cdab"})
+ end
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles invalid arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/get_module_path_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/get_module_path_spec.rb
new file mode 100644
index 0000000..f9b169c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/get_module_path_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper_acceptance'
+
+describe 'get_module_path function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = $::is_pe ? {
+ 'true' => '/etc/puppetlabs/puppet/modules/dne',
+ 'false' => '/etc/puppet/modules/dne',
+ }
+ $o = get_module_path('dne')
+ if $o == $a {
+ notify { 'output correct': }
+ } else {
+ notify { "failed; module path is '$o'": }
+ }
+ DOC
+ it 'get_module_paths dne' do
+ apply_manifest(pp, :expect_failures => true)
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/getparam_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/getparam_spec.rb
new file mode 100644
index 0000000..6ed2257
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/getparam_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper_acceptance'
+
+describe 'getparam function' do
+ describe 'success' do
+ pp = <<-DOC
+ notify { 'rspec':
+ message => 'custom rspec message',
+ }
+ $o = getparam(Notify['rspec'], 'message')
+ notice(inline_template('getparam is <%= @o.inspect %>'))
+ DOC
+ it 'getparam a notify' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{getparam is "custom rspec message"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/getvar_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/getvar_spec.rb
new file mode 100644
index 0000000..0b14afb
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/getvar_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper_acceptance'
+
+describe 'getvar function' do
+ describe 'success' do
+ pp = <<-DOC
+ class a::data { $foo = 'aoeu' }
+ include a::data
+ $b = 'aoeu'
+ $o = getvar("a::data::foo")
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'getvars from classes' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-numbers'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/grep_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/grep_spec.rb
new file mode 100644
index 0000000..1fe2027
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/grep_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper_acceptance'
+
+describe 'grep function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ['aaabbb','bbbccc','dddeee']
+ $b = 'bbb'
+ $c = ['aaabbb','bbbccc']
+ $o = grep($a,$b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'greps arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/has_interface_with_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/has_interface_with_spec.rb
new file mode 100644
index 0000000..d16dc1d
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/has_interface_with_spec.rb
@@ -0,0 +1,52 @@
+require 'spec_helper_acceptance'
+
+describe 'has_interface_with function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = $::ipaddress
+ $o = has_interface_with('ipaddress', $a)
+ notice(inline_template('has_interface_with is <%= @o.inspect %>'))
+ DOC
+ it 'has_interface_with existing ipaddress' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_interface_with is true})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = '128.0.0.1'
+ $o = has_interface_with('ipaddress', $a)
+ notice(inline_template('has_interface_with is <%= @o.inspect %>'))
+ DOC
+ it 'has_interface_with absent ipaddress' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_interface_with is false})
+ end
+ end
+
+ pp3 = <<-DOC
+ if $osfamily == 'Solaris' or $osfamily == 'Darwin' {
+ $a = 'lo0'
+ }elsif $osfamily == 'windows' {
+ $a = $::kernelmajversion ? {
+ /6\.(2|3|4)/ => 'Ethernet0',
+ /6\.(0|1)/ => 'Local_Area_Connection',
+ /5\.(1|2)/ => undef, #Broken current in facter
+ }
+ }else {
+ $a = 'lo'
+ }
+ $o = has_interface_with($a)
+ notice(inline_template('has_interface_with is <%= @o.inspect %>'))
+ DOC
+ it 'has_interface_with existing interface' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_interface_with is true})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/has_ip_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/has_ip_address_spec.rb
new file mode 100644
index 0000000..13cdd77
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/has_ip_address_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper_acceptance'
+
+describe 'has_ip_address function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = '127.0.0.1'
+ $o = has_ip_address($a)
+ notice(inline_template('has_ip_address is <%= @o.inspect %>'))
+ DOC
+ it 'has_ip_address existing ipaddress' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_ip_address is true})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = '128.0.0.1'
+ $o = has_ip_address($a)
+ notice(inline_template('has_ip_address is <%= @o.inspect %>'))
+ DOC
+ it 'has_ip_address absent ipaddress' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_ip_address is false})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/has_ip_network_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/has_ip_network_spec.rb
new file mode 100644
index 0000000..e18f050
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/has_ip_network_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper_acceptance'
+
+describe 'has_ip_network function', :unless => ((fact('osfamily') == 'windows') || (fact('osfamily') == 'AIX')) do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = '127.0.0.0'
+ $o = has_ip_network($a)
+ notice(inline_template('has_ip_network is <%= @o.inspect %>'))
+ DOC
+ it 'has_ip_network existing ipaddress' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_ip_network is true})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = '128.0.0.0'
+ $o = has_ip_network($a)
+ notice(inline_template('has_ip_network is <%= @o.inspect %>'))
+ DOC
+ it 'has_ip_network absent ipaddress' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{has_ip_network is false})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/has_key_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/has_key_spec.rb
new file mode 100644
index 0000000..9da69c2
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/has_key_spec.rb
@@ -0,0 +1,39 @@
+require 'spec_helper_acceptance'
+
+describe 'has_key function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
+ $b = 'bbb'
+ $c = true
+ $o = has_key($a,$b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'has_keys in hashes' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
+ $b = 'ccc'
+ $c = false
+ $o = has_key($a,$b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'has_keys not in hashes' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-hashes'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/hash_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/hash_spec.rb
new file mode 100644
index 0000000..82e9245
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/hash_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper_acceptance'
+
+describe 'hash function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ['aaa','bbb','bbb','ccc','ddd','eee']
+ $b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' }
+ $o = hash($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'hashs arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ it 'handles odd-length arrays'
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/intersection_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/intersection_spec.rb
new file mode 100644
index 0000000..75dfe87
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/intersection_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper_acceptance'
+
+describe 'intersection function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ['aaa','bbb','ccc']
+ $b = ['bbb','ccc','ddd','eee']
+ $c = ['bbb','ccc']
+ $o = intersection($a,$b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'intersections arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ it 'intersections empty arrays'
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_a_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_a_spec.rb
new file mode 100644
index 0000000..449e3e7
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_a_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper_acceptance'
+
+if return_puppet_version =~ %r{^4}
+ describe 'is_a function' do
+ pp1 = <<-DOC
+ if 'hello world'.is_a(String) {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'matches a string' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ if 5.is_a(String) {
+ notify { 'output wrong': }
+ }
+ DOC
+ it 'does not match a integer as string' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).not_to match(%r{Notice: output wrong})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_array_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_array_spec.rb
new file mode 100644
index 0000000..408ff1e
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_array_spec.rb
@@ -0,0 +1,65 @@
+require 'spec_helper_acceptance'
+
+describe 'is_array function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa','bbb','ccc']
+ $b = true
+ $o = is_array($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_arrays arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = []
+ $b = true
+ $o = is_array($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_arrays empty arrays' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "aoeu"
+ $b = false
+ $o = is_array($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_arrays strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = {'aaa'=>'bbb'}
+ $b = false
+ $o = is_array($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_arrays hashes' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_bool_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_bool_spec.rb
new file mode 100644
index 0000000..e9dab73
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_bool_spec.rb
@@ -0,0 +1,79 @@
+require 'spec_helper_acceptance'
+
+describe 'is_bool function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa','bbb','ccc']
+ $b = false
+ $o = is_bool($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_bools arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $b = true
+ $o = is_bool($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_bools true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = false
+ $b = true
+ $o = is_bool($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_bools false' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = "true"
+ $b = false
+ $o = is_bool($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_bools strings' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = {'aaa'=>'bbb'}
+ $b = false
+ $o = is_bool($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_bools hashes' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_domain_name_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_domain_name_spec.rb
new file mode 100644
index 0000000..b33eb7a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_domain_name_spec.rb
@@ -0,0 +1,81 @@
+require 'spec_helper_acceptance'
+
+describe 'is_domain_name function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa.com','bbb','ccc']
+ $o = is_domain_name($a)
+ notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+ DOC
+ it 'is_domain_names arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_domain_name is false})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $o = is_domain_name($a)
+ notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+ DOC
+ it 'is_domain_names true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_domain_name is false})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = false
+ $o = is_domain_name($a)
+ notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+ DOC
+ it 'is_domain_names false' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_domain_name is false})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = "3foo-bar.2bar-fuzz.com"
+ $b = true
+ $o = is_domain_name($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_domain_names strings with hyphens' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = "-bar.2bar-fuzz.com"
+ $b = false
+ $o = is_domain_name($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_domain_names strings beginning with hyphens' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp6 = <<-DOC
+ $a = {'aaa'=>'www.com'}
+ $o = is_domain_name($a)
+ notice(inline_template('is_domain_name is <%= @o.inspect %>'))
+ DOC
+ it 'is_domain_names hashes' do
+ apply_manifest(pp6, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_domain_name is false})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_float_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_float_spec.rb
new file mode 100644
index 0000000..524f338
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_float_spec.rb
@@ -0,0 +1,84 @@
+require 'spec_helper_acceptance'
+
+describe 'is_float function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa.com','bbb','ccc']
+ $o = is_float($a)
+ notice(inline_template('is_float is <%= @o.inspect %>'))
+ DOC
+ it 'is_floats arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_float is false})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $o = is_float($a)
+ notice(inline_template('is_float is <%= @o.inspect %>'))
+ DOC
+ it 'is_floats true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_float is false})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "3.5"
+ $b = true
+ $o = is_float($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_floats strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = 3.5
+ $b = true
+ $o = is_float($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_floats floats' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = 3
+ $b = false
+ $o = is_float($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_floats integers' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp6 = <<-DOC
+ $a = {'aaa'=>'www.com'}
+ $o = is_float($a)
+ notice(inline_template('is_float is <%= @o.inspect %>'))
+ DOC
+ it 'is_floats hashes' do
+ apply_manifest(pp6, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_float is false})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_function_available_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_function_available_spec.rb
new file mode 100644
index 0000000..8bb63f2
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_function_available_spec.rb
@@ -0,0 +1,56 @@
+require 'spec_helper_acceptance'
+
+describe 'is_function_available function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['fail','include','require']
+ $o = is_function_available($a)
+ notice(inline_template('is_function_available is <%= @o.inspect %>'))
+ DOC
+ it 'is_function_availables arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_function_available is false})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $o = is_function_available($a)
+ notice(inline_template('is_function_available is <%= @o.inspect %>'))
+ DOC
+ it 'is_function_availables true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_function_available is false})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "fail"
+ $b = true
+ $o = is_function_available($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_function_availables strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = "is_function_available"
+ $o = is_function_available($a)
+ notice(inline_template('is_function_available is <%= @o.inspect %>'))
+ DOC
+ it 'is_function_availables function_availables' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_function_available is true})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_hash_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_hash_spec.rb
new file mode 100644
index 0000000..c5f6b2e
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_hash_spec.rb
@@ -0,0 +1,61 @@
+require 'spec_helper_acceptance'
+
+describe 'is_hash function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa','bbb','ccc']
+ $o = is_hash($a)
+ notice(inline_template('is_hash is <%= @o.inspect %>'))
+ DOC
+ it 'is_hashs arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_hash is false})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = {}
+ $b = true
+ $o = is_hash($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_hashs empty hashs' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "aoeu"
+ $b = false
+ $o = is_hash($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_hashs strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = {'aaa'=>'bbb'}
+ $b = true
+ $o = is_hash($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_hashs hashes' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_integer_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_integer_spec.rb
new file mode 100644
index 0000000..45a8c2b
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_integer_spec.rb
@@ -0,0 +1,93 @@
+require 'spec_helper_acceptance'
+
+describe 'is_integer function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa.com','bbb','ccc']
+ $b = false
+ $o = is_integer($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_integers arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $b = false
+ $o = is_integer($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_integers true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "3"
+ $b = true
+ $o = is_integer($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_integers strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = 3.5
+ $b = false
+ $o = is_integer($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_integers floats' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = 3
+ $b = true
+ $o = is_integer($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_integers integers' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp6 = <<-DOC
+ $a = {'aaa'=>'www.com'}
+ $b = false
+ $o = is_integer($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_integers hashes' do
+ apply_manifest(pp6, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_ip_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_ip_address_spec.rb
new file mode 100644
index 0000000..e528fe5
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_ip_address_spec.rb
@@ -0,0 +1,78 @@
+require 'spec_helper_acceptance'
+
+describe 'is_ip_address function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = '1.2.3.4'
+ $b = true
+ $o = is_ip_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ip_addresss ipv4' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
+ $b = true
+ $o = is_ip_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ip_addresss ipv6' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "fe00::1"
+ $b = true
+ $o = is_ip_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ip_addresss ipv6 compressed' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = "aoeu"
+ $b = false
+ $o = is_ip_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ip_addresss strings' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = '1.2.3.400'
+ $b = false
+ $o = is_ip_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ip_addresss ipv4 out of range' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb
new file mode 100644
index 0000000..04cb45f
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_ipv4_address_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper_acceptance'
+
+describe 'is_ipv4_address function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = '1.2.3.4'
+ $b = true
+ $o = is_ipv4_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv4_addresss' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "aoeu"
+ $b = false
+ $o = is_ipv4_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv4_addresss strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = '1.2.3.400'
+ $b = false
+ $o = is_ipv4_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv4_addresss ipv4 out of range' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb
new file mode 100644
index 0000000..03e5dd1
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_ipv6_address_spec.rb
@@ -0,0 +1,64 @@
+require 'spec_helper_acceptance'
+
+describe 'is_ipv6_address function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
+ $b = true
+ $o = is_ipv6_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv6_addresss' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "fe00::1"
+ $b = true
+ $o = is_ipv6_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv6_addresss ipv6 compressed' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "aoeu"
+ $b = false
+ $o = is_ipv6_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv6_addresss strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = 'fe80:0000:cd12:d123:e2f8:47ff:fe09:gggg'
+ $b = false
+ $o = is_ipv6_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_ipv6_addresss ip out of range' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_mac_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_mac_address_spec.rb
new file mode 100644
index 0000000..8e9d64d
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_mac_address_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper_acceptance'
+
+describe 'is_mac_address function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = '00:a0:1f:12:7f:a0'
+ $b = true
+ $o = is_mac_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_mac_addresss a mac' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = '00:a0:1f:12:7f:g0'
+ $b = false
+ $o = is_mac_address($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_mac_addresss a mac out of range' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_numeric_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_numeric_spec.rb
new file mode 100644
index 0000000..4ec7f0c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_numeric_spec.rb
@@ -0,0 +1,93 @@
+require 'spec_helper_acceptance'
+
+describe 'is_numeric function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa.com','bbb','ccc']
+ $b = false
+ $o = is_numeric($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_numerics arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $b = false
+ $o = is_numeric($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_numerics true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "3"
+ $b = true
+ $o = is_numeric($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_numerics strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = 3.5
+ $b = true
+ $o = is_numeric($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_numerics floats' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = 3
+ $b = true
+ $o = is_numeric($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_numerics integers' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp6 = <<-DOC
+ $a = {'aaa'=>'www.com'}
+ $b = false
+ $o = is_numeric($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_numerics hashes' do
+ apply_manifest(pp6, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ it 'handles non-arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/is_string_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/is_string_spec.rb
new file mode 100644
index 0000000..e3ab31a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/is_string_spec.rb
@@ -0,0 +1,111 @@
+require 'spec_helper_acceptance'
+
+describe 'is_string function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa.com','bbb','ccc']
+ $b = false
+ $o = is_string($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_strings arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = true
+ $b = false
+ $o = is_string($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_strings true' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "aoeu"
+ $o = is_string($a)
+ notice(inline_template('is_string is <%= @o.inspect %>'))
+ DOC
+ it 'is_strings strings' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_string is true})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = "3"
+ $o = is_string($a)
+ notice(inline_template('is_string is <%= @o.inspect %>'))
+ DOC
+ it 'is_strings number strings' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_string is false})
+ end
+ end
+
+ pp5 = <<-DOC
+ $a = 3.5
+ $b = false
+ $o = is_string($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_strings floats' do
+ apply_manifest(pp5, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp6 = <<-DOC
+ $a = 3
+ $b = false
+ $o = is_string($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_strings integers' do
+ apply_manifest(pp6, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp7 = <<-DOC
+ $a = {'aaa'=>'www.com'}
+ $b = false
+ $o = is_string($a)
+ if $o == $b {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'is_strings hashes' do
+ apply_manifest(pp7, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ pp8 = <<-DOC
+ $a = undef
+ $o = is_string($a)
+ notice(inline_template('is_string is <%= @o.inspect %>'))
+ DOC
+ it 'is_strings undef' do
+ apply_manifest(pp8, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{is_string is true})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb
new file mode 100644
index 0000000..a9f30e3
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper_acceptance'
+
+describe 'join_keys_to_values function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = {'aaa'=>'bbb','ccc'=>'ddd'}
+ $b = ':'
+ $o = join_keys_to_values($a,$b)
+ notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>'))
+ DOC
+ it 'join_keys_to_valuess hashes' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{join_keys_to_values is \["aaa:bbb", "ccc:ddd"\]})
+ end
+ end
+ it 'handles non hashes'
+ it 'handles empty hashes'
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/join_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/join_spec.rb
new file mode 100644
index 0000000..233b953
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/join_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper_acceptance'
+
+describe 'join function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ['aaa','bbb','ccc']
+ $b = ':'
+ $c = 'aaa:bbb:ccc'
+ $o = join($a,$b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'joins arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ it 'handles non arrays'
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/keys_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/keys_spec.rb
new file mode 100644
index 0000000..9c4122c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/keys_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper_acceptance'
+
+describe 'keys function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
+ describe 'success' do
+ pp = <<-DOC
+ $a = {'aaa'=>'bbb','ccc'=>'ddd'}
+ $o = keys($a)
+ notice(inline_template('keys is <%= @o.sort.inspect %>'))
+ DOC
+ it 'keyss hashes' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{keys is \["aaa", "ccc"\]})
+ end
+ end
+ it 'handles non hashes'
+ it 'handles empty hashes'
+ end
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/loadjson_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/loadjson_spec.rb
new file mode 100644
index 0000000..31d015a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/loadjson_spec.rb
@@ -0,0 +1,48 @@
+require 'spec_helper_acceptance'
+
+tmpdir = default.tmpdir('stdlib')
+
+describe 'loadjson function' do
+ describe 'success' do
+ shell("echo '{\"aaa\":1,\"bbb\":2,\"ccc\":3,\"ddd\":4}' > #{tmpdir}/test1json.json")
+ pp1 = <<-DOC
+ $o = loadjson('#{tmpdir}/test1json.json')
+ notice(inline_template('loadjson[aaa] is <%= @o["aaa"].inspect %>'))
+ notice(inline_template('loadjson[bbb] is <%= @o["bbb"].inspect %>'))
+ notice(inline_template('loadjson[ccc] is <%= @o["ccc"].inspect %>'))
+ notice(inline_template('loadjson[ddd] is <%= @o["ddd"].inspect %>'))
+ DOC
+ regex_array = [%r{loadjson\[aaa\] is 1}, %r{loadjson\[bbb\] is 2}, %r{loadjson\[ccc\] is 3}, %r{loadjson\[ddd\] is 4}]
+ it 'loadjsons array of values' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ regex_array.each do |i|
+ expect(r.stdout).to match(i)
+ end
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = loadjson('#{tmpdir}/no-file.json', {'default' => 'value'})
+ notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>'))
+ DOC
+ it 'returns the default value if there is no file to load' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{loadjson\[default\] is "value"})
+ end
+ end
+
+ shell("echo '!' > #{tmpdir}/test2json.json")
+ pp3 = <<-DOC
+ $o = loadjson('#{tmpdir}/test2json.json', {'default' => 'value'})
+ notice(inline_template('loadjson[default] is <%= @o["default"].inspect %>'))
+ DOC
+ it 'returns the default value if the file was parsed with an error' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{loadjson\[default\] is "value"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/loadyaml_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/loadyaml_spec.rb
new file mode 100644
index 0000000..f55274c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/loadyaml_spec.rb
@@ -0,0 +1,52 @@
+require 'spec_helper_acceptance'
+
+tmpdir = default.tmpdir('stdlib')
+
+describe 'loadyaml function' do
+ describe 'success' do
+ shell("echo '---
+ aaa: 1
+ bbb: 2
+ ccc: 3
+ ddd: 4' > #{tmpdir}/test1yaml.yaml")
+ pp1 = <<-DOC
+ $o = loadyaml('#{tmpdir}/test1yaml.yaml')
+ notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>'))
+ notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>'))
+ notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>'))
+ notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>'))
+ DOC
+ regex_array = [%r{loadyaml\[aaa\] is 1}, %r{loadyaml\[bbb\] is 2}, %r{loadyaml\[ccc\] is 3}, %r{loadyaml\[ddd\] is 4}]
+ it 'loadyamls array of values' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ regex_array.each do |i|
+ expect(r.stdout).to match(i)
+ end
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = loadyaml('#{tmpdir}/no-file.yaml', {'default' => 'value'})
+ notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>'))
+ DOC
+ it 'returns the default value if there is no file to load' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{loadyaml\[default\] is "value"})
+ end
+ end
+
+ shell("echo '!' > #{tmpdir}/test2yaml.yaml")
+ pp3 = <<-DOC
+ $o = loadyaml('#{tmpdir}/test2yaml.yaml', {'default' => 'value'})
+ notice(inline_template('loadyaml[default] is <%= @o["default"].inspect %>'))
+ DOC
+ it 'returns the default value if the file was parsed with an error' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{loadyaml\[default\] is "value"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/lstrip_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/lstrip_spec.rb
new file mode 100644
index 0000000..fe9c013
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/lstrip_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper_acceptance'
+
+describe 'lstrip function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = [" the "," public "," art","galleries "]
+ # Anagram: Large picture halls, I bet
+ $o = lstrip($a)
+ notice(inline_template('lstrip is <%= @o.inspect %>'))
+ DOC
+ it 'lstrips arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{lstrip is \["the ", "public ", "art", "galleries "\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = " blowzy night-frumps vex'd jack q "
+ $o = lstrip($a)
+ notice(inline_template('lstrip is <%= @o.inspect %>'))
+ DOC
+ it 'lstrips strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{lstrip is "blowzy night-frumps vex'd jack q "})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/max_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/max_spec.rb
new file mode 100644
index 0000000..9482871
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/max_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper_acceptance'
+
+describe 'max function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = max("the","public","art","galleries")
+ notice(inline_template('max is <%= @o.inspect %>'))
+ DOC
+ it 'maxs arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{max is "the"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/member_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/member_spec.rb
new file mode 100644
index 0000000..ebadeb4
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/member_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper_acceptance'
+
+describe 'member function' do
+ shared_examples 'item found' do
+ it 'outputs correctly' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+ end
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ['aaa','bbb','ccc']
+ $b = 'ccc'
+ $c = true
+ $o = member($a,$b)
+ if $o == $c {
+ notify { 'output correct': }
+ }
+ DOC
+ it 'members arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{Notice: output correct})
+ end
+ end
+
+ describe 'members array of integers' do
+ let(:pp) do
+ <<-DOC
+ if member( [1,2,3,4], 4 ){
+ notify { 'output correct': }
+ }
+ DOC
+ end
+
+ it_behaves_like 'item found' do
+ end
+ end
+ describe 'members of mixed array' do
+ let(:pp) do
+ <<-DOC
+ if member( ['a','4',3], 'a' ){
+ notify { 'output correct': }
+ }
+ DOC
+ end
+
+ it_behaves_like 'item found' do
+ end
+ end
+ it 'members arrays without members'
+ end
+
+ describe 'failure' do
+ it 'handles improper argument counts'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/merge_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/merge_spec.rb
new file mode 100644
index 0000000..17e2b9e
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/merge_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper_acceptance'
+
+describe 'merge function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
+ $b = {'two' => 'dos', 'three' => { 'five' => 5 } }
+ $o = merge($a, $b)
+ notice(inline_template('merge[one] is <%= @o["one"].inspect %>'))
+ notice(inline_template('merge[two] is <%= @o["two"].inspect %>'))
+ notice(inline_template('merge[three] is <%= @o["three"].inspect %>'))
+ DOC
+ regex_array = [%r{merge\[one\] is ("1"|1)}, %r{merge\[two\] is "dos"}, %r{merge\[three\] is {"five"=>("5"|5)}}]
+ it 'merges two hashes' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ regex_array.each do |i|
+ expect(r.stdout).to match(i)
+ end
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/min_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/min_spec.rb
new file mode 100644
index 0000000..deb6605
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/min_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper_acceptance'
+
+describe 'min function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = min("the","public","art","galleries")
+ notice(inline_template('min is <%= @o.inspect %>'))
+ DOC
+ it 'mins arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{min is "art"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml
new file mode 100644
index 0000000..5eebdef
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/centos-7-x64.yml
@@ -0,0 +1,10 @@
+HOSTS:
+ centos-7-x64:
+ roles:
+ - agent
+ - default
+ platform: el-7-x86_64
+ hypervisor: vagrant
+ box: puppetlabs/centos-7.2-64-nocm
+CONFIG:
+ type: foss
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml
new file mode 100644
index 0000000..fef6e63
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/debian-8-x64.yml
@@ -0,0 +1,10 @@
+HOSTS:
+ debian-8-x64:
+ roles:
+ - agent
+ - default
+ platform: debian-8-amd64
+ hypervisor: vagrant
+ box: puppetlabs/debian-8.2-64-nocm
+CONFIG:
+ type: foss
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/nodesets/default.yml b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/default.yml
new file mode 100644
index 0000000..dba339c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/default.yml
@@ -0,0 +1,10 @@
+HOSTS:
+ ubuntu-1404-x64:
+ roles:
+ - agent
+ - default
+ platform: ubuntu-14.04-amd64
+ hypervisor: vagrant
+ box: puppetlabs/ubuntu-14.04-64-nocm
+CONFIG:
+ type: foss
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml
new file mode 100644
index 0000000..a3333aa
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/centos-7.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ centos-7-x64:
+ platform: el-7-x86_64
+ hypervisor: docker
+ image: centos:7
+ docker_preserve_image: true
+ docker_cmd: '["/usr/sbin/init"]'
+ # install various tools required to get the image up to usable levels
+ docker_image_commands:
+ - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts'
+CONFIG:
+ trace_limit: 200
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml
new file mode 100644
index 0000000..df5c319
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/debian-8.yml
@@ -0,0 +1,11 @@
+HOSTS:
+ debian-8-x64:
+ platform: debian-8-amd64
+ hypervisor: docker
+ image: debian:8
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen'
+CONFIG:
+ trace_limit: 200
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml
new file mode 100644
index 0000000..b1efa58
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/nodesets/docker/ubuntu-14.04.yml
@@ -0,0 +1,12 @@
+HOSTS:
+ ubuntu-1404-x64:
+ platform: ubuntu-14.04-amd64
+ hypervisor: docker
+ image: ubuntu:14.04
+ docker_preserve_image: true
+ docker_cmd: '["/sbin/init"]'
+ docker_image_commands:
+ # ensure that upstart is booting correctly in the container
+ - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8'
+CONFIG:
+ trace_limit: 200
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/num2bool_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/num2bool_spec.rb
new file mode 100644
index 0000000..d95cb93
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/num2bool_spec.rb
@@ -0,0 +1,76 @@
+require 'spec_helper_acceptance'
+
+describe 'num2bool function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = 1
+ $b = "1"
+ $c = "50"
+ $ao = num2bool($a)
+ $bo = num2bool($b)
+ $co = num2bool($c)
+ notice(inline_template('a is <%= @ao.inspect %>'))
+ notice(inline_template('b is <%= @bo.inspect %>'))
+ notice(inline_template('c is <%= @co.inspect %>'))
+ DOC
+ regex_array_true = [%r{a is true}, %r{b is true}, %r{c is true}]
+ it 'bools positive numbers and numeric strings as true' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ regex_array_true.each do |i|
+ expect(r.stdout).to match(i)
+ end
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = 0
+ $b = -0.1
+ $c = ["-50","1"]
+ $ao = num2bool($a)
+ $bo = num2bool($b)
+ $co = num2bool($c)
+ notice(inline_template('a is <%= @ao.inspect %>'))
+ notice(inline_template('b is <%= @bo.inspect %>'))
+ notice(inline_template('c is <%= @co.inspect %>'))
+ DOC
+ regex_array_false = [%r{a is false}, %r{b is false}, %r{c is false}]
+ it 'bools negative numbers as false' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ regex_array_false.each do |i|
+ expect(r.stdout).to match(i)
+ end
+ end
+ end
+ end
+
+ describe 'failure' do
+ pp3 = <<-DOC
+ $a = "a"
+ $ao = num2bool($a)
+ notice(inline_template('a is <%= @ao.inspect %>'))
+ DOC
+ it 'fails on words' do
+ expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{not look like a number})
+ end
+
+ pp4 = <<-DOC
+ $b = "1b"
+ $bo = num2bool($b)
+ notice(inline_template('b is <%= @bo.inspect %>'))
+ DOC
+ it 'fails on numberwords' do
+ expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{not look like a number})
+ end
+
+ pp5 = <<-DOC # rubocop:disable Lint/UselessAssignment
+ $c = {"c" => "-50"}
+ $co = num2bool($c)
+ notice(inline_template('c is <%= @co.inspect %>'))
+ DOC
+ it 'fails on non-numeric/strings' do
+ pending "The function will call .to_s.to_i on anything not a Numeric or
+ String, and results in 0. Is this intended?"
+ expect(apply_manifest(pp5(:expect_failures => true)).stderr).to match(%r{Unable to parse})
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/parsejson_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/parsejson_spec.rb
new file mode 100644
index 0000000..8a19907
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/parsejson_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper_acceptance'
+
+describe 'parsejson function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = '{"hunter": "washere", "tests": "passing"}'
+ $ao = parsejson($a)
+ $tests = $ao['tests']
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ DOC
+ it 'parses valid json' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{tests are "passing"})
+ end
+ end
+ end
+
+ describe 'failure' do
+ pp2 = <<-DOC
+ $a = '{"hunter": "washere", "tests": "passing",}'
+ $ao = parsejson($a, 'tests are using the default value')
+ notice(inline_template('a is <%= @ao.inspect %>'))
+ DOC
+ it 'raises error on incorrect json - default value is used' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{tests are using the default value})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = '{"hunter": "washere", "tests": "passing",}'
+ $ao = parsejson($a)
+ notice(inline_template('a is <%= @ao.inspect %>'))
+ DOC
+ it 'raises error on incorrect json' do
+ apply_manifest(pp3, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{expected next name})
+ end
+ end
+
+ pp4 = <<-DOC
+ $o = parsejson()
+ DOC
+ it 'raises error on incorrect number of arguments' do
+ apply_manifest(pp4, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{wrong number of arguments}i)
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/parseyaml_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/parseyaml_spec.rb
new file mode 100644
index 0000000..4cdf36d
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/parseyaml_spec.rb
@@ -0,0 +1,52 @@
+require 'spec_helper_acceptance'
+
+describe 'parseyaml function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = "---\nhunter: washere\ntests: passing\n"
+ $o = parseyaml($a)
+ $tests = $o['tests']
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ DOC
+ it 'parses valid yaml' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{tests are "passing"})
+ end
+ end
+ end
+
+ describe 'failure' do
+ pp2 = <<-DOC
+ $a = "---\nhunter: washere\ntests: passing\n:"
+ $o = parseyaml($a, {'tests' => 'using the default value'})
+ $tests = $o['tests']
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ DOC
+ it 'returns the default value on incorrect yaml' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{tests are "using the default value"})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "---\nhunter: washere\ntests: passing\n:"
+ $o = parseyaml($a)
+ $tests = $o['tests']
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ DOC
+ it 'raises error on incorrect yaml' do
+ apply_manifest(pp3, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{(syntax error|did not find expected key)})
+ end
+ end
+
+ pp4 = <<-DOC
+ $o = parseyaml()
+ DOC
+ it 'raises error on incorrect number of arguments' do
+ apply_manifest(pp4, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{wrong number of arguments}i)
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/pick_default_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/pick_default_spec.rb
new file mode 100644
index 0000000..82b7ea5
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/pick_default_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper_acceptance'
+
+describe 'pick_default function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = undef
+ $o = pick_default($a, 'default')
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'pick_defaults a default value' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{picked is "default"})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = undef
+ $b = undef
+ $o = pick_default($a,$b)
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'pick_defaults with no value' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{picked is ""})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "something"
+ $b = "long"
+ $o = pick_default($a, $b, 'default')
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'pick_defaults the first set value' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{picked is "something"})
+ end
+ end
+ end
+ describe 'failure' do
+ pp4 = <<-DOC
+ $o = pick_default()
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'raises error with no values' do
+ apply_manifest(pp4, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{Must receive at least one argument})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/pick_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/pick_spec.rb
new file mode 100644
index 0000000..14834b4
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/pick_spec.rb
@@ -0,0 +1,42 @@
+require 'spec_helper_acceptance'
+
+describe 'pick function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = undef
+ $o = pick($a, 'default')
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'picks a default value' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{picked is "default"})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "something"
+ $b = "long"
+ $o = pick($a, $b, 'default')
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'picks the first set value' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{picked is "something"})
+ end
+ end
+ end
+
+ describe 'failure' do
+ pp3 = <<-DOC
+ $a = undef
+ $b = undef
+ $o = pick($a, $b)
+ notice(inline_template('picked is <%= @o.inspect %>'))
+ DOC
+ it 'raises error with all undef values' do
+ apply_manifest(pp3, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{must receive at least one non empty value})
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/prefix_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/prefix_spec.rb
new file mode 100644
index 0000000..9a37fb3
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/prefix_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper_acceptance'
+
+describe 'prefix function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $o = prefix(['a','b','c'],'p')
+ notice(inline_template('prefix is <%= @o.inspect %>'))
+ DOC
+ it 'prefixes array of values' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{prefix is \["pa", "pb", "pc"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = prefix([],'p')
+ notice(inline_template('prefix is <%= @o.inspect %>'))
+ DOC
+ it 'prefixs with empty array' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{prefix is \[\]})
+ end
+ end
+
+ pp3 = <<-DOC
+ $o = prefix(['a','b','c'], undef)
+ notice(inline_template('prefix is <%= @o.inspect %>'))
+ DOC
+ it 'prefixs array of values with undef' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{prefix is \["a", "b", "c"\]})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ it 'fails when first argument is not array'
+ it 'fails when second argument is not string'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/pw_hash_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/pw_hash_spec.rb
new file mode 100644
index 0000000..f6e2928
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/pw_hash_spec.rb
@@ -0,0 +1,31 @@
+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 'success' do
+ pp1 = <<-DOC
+ $o = pw_hash('password', 'sha-512', 'salt')
+ notice(inline_template('pw_hash is <%= @o.inspect %>'))
+ DOC
+ it 'hashes passwords' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{pw_hash is "\$6\$salt\$IxDD3jeSOb5eB1CX5LBsqZFVkJdido3OUILO5Ifz5iwMuTS4XMS130MTSuDDl3aCI6WouIL9AjRbLCelDCy\.g\."})
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = pw_hash('', 'sha-512', 'salt')
+ notice(inline_template('pw_hash is <%= @o.inspect %>'))
+ DOC
+ it 'returns nil if no password is provided' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{pw_hash is nil})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles less than three arguments'
+ it 'handles more than three arguments'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/range_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/range_spec.rb
new file mode 100644
index 0000000..a5a7d22
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/range_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper_acceptance'
+
+describe 'range function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $o = range('a','d')
+ notice(inline_template('range is <%= @o.inspect %>'))
+ DOC
+ it 'ranges letters' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{range is \["a", "b", "c", "d"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = range('a','d', '2')
+ notice(inline_template('range is <%= @o.inspect %>'))
+ DOC
+ it 'ranges letters with a step' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{range is \["a", "c"\]})
+ end
+ end
+ it 'ranges letters with a negative step'
+ it 'ranges numbers'
+ it 'ranges numbers with a step'
+ it 'ranges numbers with a negative step'
+ it 'ranges numeric strings'
+ it 'ranges zero padded numbers'
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/reject_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/reject_spec.rb
new file mode 100644
index 0000000..753dd78
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/reject_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper_acceptance'
+
+describe 'reject function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
+ notice(inline_template('reject is <%= @o.inspect %>'))
+ DOC
+ it 'rejects array of values' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{reject is \["bbb", "ccc"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = reject([],'aaa')
+ notice(inline_template('reject is <%= @o.inspect %>'))
+ DOC
+ it 'rejects with empty array' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{reject is \[\]})
+ end
+ end
+
+ pp3 = <<-DOC
+ $o = reject(['aaa','bbb','ccc','aaaddd'], undef)
+ notice(inline_template('reject is <%= @o.inspect %>'))
+ DOC
+ it 'rejects array of values with undef' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{reject is \[\]})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ it 'fails when first argument is not array'
+ it 'fails when second argument is not string'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/reverse_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/reverse_spec.rb
new file mode 100644
index 0000000..393fc30
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/reverse_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper_acceptance'
+
+describe 'reverse function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = "the public art galleries"
+ # Anagram: Large picture halls, I bet
+ $o = reverse($a)
+ notice(inline_template('reverse is <%= @o.inspect %>'))
+ DOC
+ it 'reverses strings' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{reverse is "seirellag tra cilbup eht"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/rstrip_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/rstrip_spec.rb
new file mode 100644
index 0000000..60c5fff
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/rstrip_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper_acceptance'
+
+describe 'rstrip function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = [" the "," public "," art","galleries "]
+ # Anagram: Large picture halls, I bet
+ $o = rstrip($a)
+ notice(inline_template('rstrip is <%= @o.inspect %>'))
+ DOC
+ it 'rstrips arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{rstrip is \[" the", " public", " art", "galleries"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = " blowzy night-frumps vex'd jack q "
+ $o = rstrip($a)
+ notice(inline_template('rstrip is <%= @o.inspect %>'))
+ DOC
+ it 'rstrips strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{rstrip is " blowzy night-frumps vex'd jack q"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/shuffle_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/shuffle_spec.rb
new file mode 100644
index 0000000..d8c03a2
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/shuffle_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper_acceptance'
+
+describe 'shuffle function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"]
+ # Anagram: Large picture halls, I bet
+ $o = shuffle($a)
+ notice(inline_template('shuffle is <%= @o.inspect %>'))
+ DOC
+ it 'shuffles arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).not_to match(%r{shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "blowzy night-frumps vex'd jack q"
+ $o = shuffle($a)
+ notice(inline_template('shuffle is <%= @o.inspect %>'))
+ DOC
+ it 'shuffles strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).not_to match(%r{shuffle is "blowzy night-frumps vex'd jack q"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/size_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/size_spec.rb
new file mode 100644
index 0000000..015488d
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/size_spec.rb
@@ -0,0 +1,53 @@
+require 'spec_helper_acceptance'
+
+describe 'size function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = 'discombobulate'
+ $o = size($a)
+ notice(inline_template('size is <%= @o.inspect %>'))
+ DOC
+ it 'single string size' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 14})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = ''
+ $o = size($a)
+ notice(inline_template('size is <%= @o.inspect %>'))
+ DOC
+ it 'with empty string' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 0})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = undef
+ $o = size($a)
+ notice(inline_template('size is <%= @o.inspect %>'))
+ DOC
+ it 'with undef' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 0})
+ end
+ end
+
+ pp4 = <<-DOC
+ $a = ['discombobulate', 'moo']
+ $o = size($a)
+ notice(inline_template('size is <%= @o.inspect %>'))
+ DOC
+ it 'strings in array' do
+ apply_manifest(pp4, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{size is 2})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/sort_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/sort_spec.rb
new file mode 100644
index 0000000..561fc68
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/sort_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper_acceptance'
+
+describe 'sort function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ["the","public","art","galleries"]
+ # Anagram: Large picture halls, I bet
+ $o = sort($a)
+ notice(inline_template('sort is <%= @o.inspect %>'))
+ DOC
+ it 'sorts arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{sort is \["art", "galleries", "public", "the"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "blowzy night-frumps vex'd jack q"
+ $o = sort($a)
+ notice(inline_template('sort is <%= @o.inspect %>'))
+ DOC
+ it 'sorts strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{sort is " '-abcdefghijklmnopqrstuvwxyz"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/squeeze_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/squeeze_spec.rb
new file mode 100644
index 0000000..c3be9db
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/squeeze_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper_acceptance'
+
+describe 'squeeze function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ # Real words!
+ $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
+ $o = squeeze($a)
+ notice(inline_template('squeeze is <%= @o.inspect %>'))
+ DOC
+ it 'squeezes arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]})
+ end
+ end
+
+ it 'squeezez arrays with an argument'
+ pp2 = <<-DOC
+ $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
+ $o = squeeze($a)
+ notice(inline_template('squeeze is <%= @o.inspect %>'))
+ DOC
+ it 'squeezes strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{squeeze is "wales laparohysterosalpingophorectomy br godeship"})
+ end
+ end
+
+ pp3 = <<-DOC
+ $a = "countessship duchessship governessship hostessship"
+ $o = squeeze($a, 's')
+ notice(inline_template('squeeze is <%= @o.inspect %>'))
+ DOC
+ it 'squeezes strings with an argument' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{squeeze is "counteship ducheship governeship hosteship"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/str2bool_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/str2bool_spec.rb
new file mode 100644
index 0000000..809456a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/str2bool_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper_acceptance'
+
+describe 'str2bool function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = str2bool('y')
+ notice(inline_template('str2bool is <%= @o.inspect %>'))
+ DOC
+ it 'works with "y"' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{str2bool is true})
+ end
+ end
+ it 'works with "Y"'
+ it 'works with "yes"'
+ it 'works with "1"'
+ it 'works with "true"'
+ it 'works with "n"'
+ it 'works with "N"'
+ it 'works with "no"'
+ it 'works with "0"'
+ it 'works with "false"'
+ it 'works with undef'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non arrays or strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb
new file mode 100644
index 0000000..4e38e07
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper_acceptance'
+
+describe 'str2saltedsha512 function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = str2saltedsha512('password')
+ notice(inline_template('str2saltedsha512 is <%= @o.inspect %>'))
+ DOC
+ it 'works with "y"' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{str2saltedsha512 is "[a-f0-9]{136}"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles more than one argument'
+ it 'handles non strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/strftime_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/strftime_spec.rb
new file mode 100644
index 0000000..eec9a60
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/strftime_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper_acceptance'
+
+describe 'strftime function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = strftime('%C')
+ notice(inline_template('strftime is <%= @o.inspect %>'))
+ DOC
+ it 'gives the Century' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{strftime is "20"})
+ end
+ end
+ it 'takes a timezone argument'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles invalid format strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/strip_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/strip_spec.rb
new file mode 100644
index 0000000..5c4dfbd
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/strip_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper_acceptance'
+
+describe 'strip function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = [" the "," public "," art","galleries "]
+ # Anagram: Large picture halls, I bet
+ $o = strip($a)
+ notice(inline_template('strip is <%= @o.inspect %>'))
+ DOC
+ it 'strips arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{strip is \["the", "public", "art", "galleries"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = " blowzy night-frumps vex'd jack q "
+ $o = strip($a)
+ notice(inline_template('strip is <%= @o.inspect %>'))
+ DOC
+ it 'strips strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{strip is "blowzy night-frumps vex'd jack q"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/suffix_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/suffix_spec.rb
new file mode 100644
index 0000000..6b04095
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/suffix_spec.rb
@@ -0,0 +1,40 @@
+require 'spec_helper_acceptance'
+
+describe 'suffix function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $o = suffix(['a','b','c'],'p')
+ notice(inline_template('suffix is <%= @o.inspect %>'))
+ DOC
+ it 'suffixes array of values' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{suffix is \["ap", "bp", "cp"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = suffix([],'p')
+ notice(inline_template('suffix is <%= @o.inspect %>'))
+ DOC
+ it 'suffixs with empty array' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{suffix is \[\]})
+ end
+ end
+
+ pp3 = <<-DOC
+ $o = suffix(['a','b','c'], undef)
+ notice(inline_template('suffix is <%= @o.inspect %>'))
+ DOC
+ it 'suffixs array of values with undef' do
+ apply_manifest(pp3, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{suffix is \["a", "b", "c"\]})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'fails with no arguments'
+ it 'fails when first argument is not array'
+ it 'fails when second argument is not string'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/swapcase_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/swapcase_spec.rb
new file mode 100644
index 0000000..1d606f0
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/swapcase_spec.rb
@@ -0,0 +1,20 @@
+require 'spec_helper_acceptance'
+
+describe 'swapcase function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = swapcase('aBcD')
+ notice(inline_template('swapcase is <%= @o.inspect %>'))
+ DOC
+ it 'works with strings' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{swapcase is "AbCd"})
+ end
+ end
+ it 'works with arrays'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non arrays or strings'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/time_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/time_spec.rb
new file mode 100644
index 0000000..b0a4564
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/time_spec.rb
@@ -0,0 +1,32 @@
+require 'spec_helper_acceptance'
+
+describe 'time function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $o = time()
+ notice(inline_template('time is <%= @o.inspect %>'))
+ DOC
+ it 'gives the time' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ m = r.stdout.match(%r{time is (\d+)\D})
+ # When I wrote this test
+ expect(Integer(m[1])).to be > 1_398_894_170
+ end
+ end
+
+ pp2 = <<-DOC
+ $o = time('UTC')
+ notice(inline_template('time is <%= @o.inspect %>'))
+ DOC
+ it 'takes a timezone argument' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ m = r.stdout.match(%r{time is (\d+)\D})
+ expect(Integer(m[1])).to be > 1_398_894_170
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles more arguments'
+ it 'handles invalid timezones'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/to_bytes_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/to_bytes_spec.rb
new file mode 100644
index 0000000..f042fe0
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/to_bytes_spec.rb
@@ -0,0 +1,25 @@
+require 'spec_helper_acceptance'
+
+describe 'to_bytes function' do
+ describe 'success' do
+ pp = <<-DOC
+ $o = to_bytes('4 kB')
+ notice(inline_template('to_bytes is <%= @o.inspect %>'))
+ DOC
+ it 'converts kB to B' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ m = r.stdout.match(%r{to_bytes is (\d+)\D})
+ expect(m[1]).to eq('4096')
+ end
+ end
+ it 'works without the B in unit'
+ it 'works without a space before unit'
+ it 'works without a unit'
+ it 'converts fractions'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non integer arguments'
+ it 'handles unknown units like uB'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/try_get_value_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/try_get_value_spec.rb
new file mode 100644
index 0000000..1112813
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/try_get_value_spec.rb
@@ -0,0 +1,44 @@
+require 'spec_helper_acceptance'
+
+describe 'try_get_value function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $data = {
+ 'a' => { 'b' => 'passing'}
+ }
+
+ $tests = try_get_value($data, 'a/b')
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ DOC
+ it 'gets a value' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{tests are "passing"})
+ end
+ end
+ end
+
+ describe 'failure' do
+ pp2 = <<-DOC
+ $data = {
+ 'a' => { 'b' => 'passing'}
+ }
+
+ $tests = try_get_value($data, 'c/d', 'using the default value')
+ notice(inline_template('tests are <%= @tests.inspect %>'))
+ DOC
+ it 'uses a default value' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{using the default value})
+ end
+ end
+
+ pp = <<-DOC
+ $o = try_get_value()
+ DOC
+ it 'raises error on incorrect number of arguments' do
+ apply_manifest(pp, :expect_failures => true) do |r|
+ expect(r.stderr).to match(%r{wrong number of arguments}i)
+ end
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/type3x_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/type3x_spec.rb
new file mode 100644
index 0000000..4b75548
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/type3x_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper_acceptance'
+
+describe 'type3x function' do
+ describe 'success' do
+ {
+ %{type3x({ 'a' => 'hash' })} => 'Hash',
+ %{type3x(['array'])} => 'Array',
+ %{type3x(false)} => 'Boolean',
+ %{type3x('asdf')} => 'String',
+ %{type3x(242)} => 'Integer',
+ %{type3x(3.14)} => 'Float',
+ }.each do |pp, type|
+ it "with type #{type}" do
+ apply_manifest(pp, :catch_failures => true)
+ end
+ end
+ end
+
+ describe 'failure' do
+ pp_fail = <<-MANIFEST
+ type3x('one','two')
+ MANIFEST
+ it 'handles improper number of arguments' do
+ expect(apply_manifest(pp_fail, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/type_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/type_spec.rb
new file mode 100644
index 0000000..7b6e1fb
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/type_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper_acceptance'
+
+describe 'type function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ["the","public","art","galleries"]
+ # Anagram: Large picture halls, I bet
+ $o = type($a)
+ notice(inline_template('type is <%= @o.to_s %>'))
+ DOC
+ it 'types arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{type is Tuple\[String.*, String.*, String.*, String.*\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "blowzy night-frumps vex'd jack q"
+ $o = type($a)
+ notice(inline_template('type is <%= @o.to_s %>'))
+ DOC
+ it 'types strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{type is String})
+ end
+ end
+ it 'types hashes'
+ it 'types integers'
+ it 'types floats'
+ it 'types booleans'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/union_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/union_spec.rb
new file mode 100644
index 0000000..e1b3d9a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/union_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper_acceptance'
+
+describe 'union function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ["the","public"]
+ $b = ["art"]
+ $c = ["galleries"]
+ # Anagram: Large picture halls, I bet
+ $o = union($a,$b,$c)
+ notice(inline_template('union is <%= @o.inspect %>'))
+ DOC
+ it 'unions arrays' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{union is \["the", "public", "art", "galleries"\]})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/unique_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/unique_spec.rb
new file mode 100644
index 0000000..614eae5
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/unique_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper_acceptance'
+
+describe 'unique function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ["wallless", "wallless", "brrr", "goddessship"]
+ $o = unique($a)
+ notice(inline_template('unique is <%= @o.inspect %>'))
+ DOC
+ it 'uniques arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{unique is \["wallless", "brrr", "goddessship"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
+ $o = unique($a)
+ notice(inline_template('unique is <%= @o.inspect %>'))
+ DOC
+ it 'uniques strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{unique is "wales prohytingcmbd"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/upcase_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/upcase_spec.rb
new file mode 100644
index 0000000..a93c192
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/upcase_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper_acceptance'
+
+describe 'upcase function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
+ $o = upcase($a)
+ notice(inline_template('upcase is <%= @o.inspect %>'))
+ DOC
+ it 'upcases arrays' do
+ apply_manifest(pp1, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]})
+ end
+ end
+
+ pp2 = <<-DOC
+ $a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
+ $o = upcase($a)
+ notice(inline_template('upcase is <%= @o.inspect %>'))
+ DOC
+ it 'upcases strings' do
+ apply_manifest(pp2, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/uriescape_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/uriescape_spec.rb
new file mode 100644
index 0000000..9553625
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/uriescape_spec.rb
@@ -0,0 +1,21 @@
+require 'spec_helper_acceptance'
+
+describe 'uriescape function' do
+ describe 'success' do
+ pp = <<-DOC
+ $a = ":/?#[]@!$&'()*+,;= \\\"{}"
+ $o = uriescape($a)
+ notice(inline_template('uriescape is <%= @o.inspect %>'))
+ DOC
+ it 'uriescape strings' do
+ apply_manifest(pp, :catch_failures => true) do |r|
+ expect(r.stdout).to match(%r{uriescape is ":\/\?%23\[\]@!\$&'\(\)\*\+,;=%20%22%7B%7D"})
+ end
+ end
+ it 'does nothing if a string is already safe'
+ end
+ describe 'failure' do
+ it 'handles no arguments'
+ it 'handles non strings or arrays'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb
new file mode 100644
index 0000000..3046459
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper_acceptance'
+
+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|
+ pp = <<-DOC
+ $one = '#{path}'
+ validate_absolute_path($one)
+ DOC
+ it "validates a single argument #{path}" do
+ apply_manifest(pp, :catch_failures => true)
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ it 'handles relative paths'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_array_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_array_spec.rb
new file mode 100644
index 0000000..87016c2
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_array_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_array function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = ['a', 'b']
+ validate_array($one)
+ DOC
+ it 'validates a single argument' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = ['a', 'b']
+ $two = [['c'], 'd']
+ validate_array($one,$two)
+ DOC
+ it 'validates an multiple arguments' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+ [
+ %{validate_array({'a' => 'hash' })},
+ %{validate_array('string')},
+ %{validate_array(false)},
+ %{validate_array(undef)},
+ ].each do |pp|
+ it "rejects #{pp.inspect}" do
+ expect(apply_manifest(pp, :expect_failures => true).stderr).to match(%r{is not an Array\. It looks to be a})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_augeas_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_augeas_spec.rb
new file mode 100644
index 0000000..9a59f38
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_augeas_spec.rb
@@ -0,0 +1,61 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_augeas function', :unless => (fact('osfamily') == 'windows') do
+ describe 'prep' do
+ it 'installs augeas for tests'
+ end
+ describe 'success' do
+ context 'with valid inputs with no 3rd argument' do
+ {
+ 'root:x:0:0:root:/root:/bin/bash\n' => 'Passwd.lns',
+ 'proc /proc proc nodev,noexec,nosuid 0 0\n' => 'Fstab.lns',
+ }.each do |line, lens|
+ pp1 = <<-DOC
+ $line = "#{line}"
+ $lens = "#{lens}"
+ validate_augeas($line, $lens)
+ DOC
+ it "validates a single argument for #{lens}" do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+ end
+ end
+
+ context 'with valid inputs with 3rd and 4th arguments' do
+ line = 'root:x:0:0:root:/root:/bin/barsh\n'
+ lens = 'Passwd.lns'
+ restriction = '$file/*[shell="/bin/barsh"]'
+ pp2 = <<-DOC
+ $line = "#{line}"
+ $lens = "#{lens}"
+ $restriction = ['#{restriction}']
+ validate_augeas($line, $lens, $restriction, "my custom failure message")
+ DOC
+ it 'validates a restricted value' do
+ expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{my custom failure message})
+ end
+ end
+
+ context 'with invalid inputs' do
+ {
+ 'root:x:0:0:root' => 'Passwd.lns',
+ '127.0.1.1' => 'Hosts.lns',
+ }.each do |line, lens|
+ pp3 = <<-DOC
+ $line = "#{line}"
+ $lens = "#{lens}"
+ validate_augeas($line, $lens)
+ DOC
+ it "validates a single argument for #{lens}" do
+ apply_manifest(pp3, :expect_failures => true)
+ end
+ end
+ end
+ context 'with garbage inputs' do
+ it 'raises an error on invalid inputs'
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_bool_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_bool_spec.rb
new file mode 100644
index 0000000..fb3ec14
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_bool_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_bool function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = true
+ validate_bool($one)
+ DOC
+ it 'validates a single argument' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = true
+ $two = false
+ validate_bool($one,$two)
+ DOC
+ it 'validates an multiple arguments' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+ [
+ %{validate_bool('true')},
+ %{validate_bool('false')},
+ %{validate_bool([true])},
+ %{validate_bool(undef)},
+ ].each do |pp3|
+ it "rejects #{pp3.inspect}" do
+ expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{is not a boolean\. It looks to be a})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_cmd_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_cmd_spec.rb
new file mode 100644
index 0000000..a846b53
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_cmd_spec.rb
@@ -0,0 +1,50 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_cmd function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = 'foo'
+ if $::osfamily == 'windows' {
+ $two = 'echo' #shell built-in
+ } else {
+ $two = '/bin/echo'
+ }
+ validate_cmd($one,$two)
+ DOC
+ it 'validates a true command' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = 'foo'
+ if $::osfamily == 'windows' {
+ $two = 'C:/aoeu'
+ } else {
+ $two = '/bin/aoeu'
+ }
+ validate_cmd($one,$two)
+ DOC
+ it 'validates a fail command' do
+ apply_manifest(pp2, :expect_failures => true)
+ end
+
+ pp3 = <<-DOC
+ $one = 'foo'
+ if $::osfamily == 'windows' {
+ $two = 'C:/aoeu'
+ } else {
+ $two = '/bin/aoeu'
+ }
+ validate_cmd($one,$two,"aoeu is dvorak")
+ DOC
+ it 'validates a fail command with a custom error message' do
+ apply_manifest(pp3, :expect_failures => true) do |output|
+ expect(output.stderr).to match(%r{aoeu is dvorak})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ it 'handles improper argument types'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_hash_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_hash_spec.rb
new file mode 100644
index 0000000..c349020
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_hash_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_hash function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = { 'a' => 1 }
+ validate_hash($one)
+ DOC
+ it 'validates a single argument' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = { 'a' => 1 }
+ $two = { 'b' => 2 }
+ validate_hash($one,$two)
+ DOC
+ it 'validates an multiple arguments' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+
+ [
+ %{validate_hash('{ "not" => "hash" }')},
+ %{validate_hash('string')},
+ %{validate_hash(["array"])},
+ %{validate_hash(undef)},
+ ].each do |pp3|
+ it "rejects #{pp3.inspect}" do
+ expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb
new file mode 100644
index 0000000..3ea165a
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_ipv4_address function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = '1.2.3.4'
+ validate_ipv4_address($one)
+ DOC
+ it 'validates a single argument' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = '1.2.3.4'
+ $two = '5.6.7.8'
+ validate_ipv4_address($one,$two)
+ DOC
+ it 'validates an multiple arguments' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ it 'handles ipv6 addresses'
+ it 'handles non-ipv4 strings'
+ it 'handles numbers'
+ it 'handles no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb
new file mode 100644
index 0000000..c329331
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_ipv6_address function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = '3ffe:0505:0002::'
+ validate_ipv6_address($one)
+ DOC
+ it 'validates a single argument' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = '3ffe:0505:0002::'
+ $two = '3ffe:0505:0001::'
+ validate_ipv6_address($one,$two)
+ DOC
+ it 'validates an multiple arguments' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ it 'handles ipv6 addresses'
+ it 'handles non-ipv6 strings'
+ it 'handles numbers'
+ it 'handles no arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_re_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_re_spec.rb
new file mode 100644
index 0000000..2d2291c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_re_spec.rb
@@ -0,0 +1,46 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_re function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = 'one'
+ $two = '^one$'
+ validate_re($one,$two)
+ DOC
+ it 'validates a string' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = 'one'
+ $two = ['^one$', '^two']
+ validate_re($one,$two)
+ DOC
+ it 'validates an array' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+
+ pp3 = <<-DOC
+ $one = 'one'
+ $two = ['^two$', '^three']
+ validate_re($one,$two)
+ DOC
+ it 'validates a failed array' do
+ apply_manifest(pp3, :expect_failures => true)
+ end
+
+ pp4 = <<-DOC
+ $one = '3.4.3'
+ $two = '^2.7'
+ validate_re($one,$two,"The $puppetversion fact does not match 2.7")
+ DOC
+ it 'validates a failed array with a custom error message' do
+ expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{does not match})
+ end
+ end
+
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ it 'handles improper argument types'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_slength_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_slength_spec.rb
new file mode 100644
index 0000000..afbb97b
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_slength_spec.rb
@@ -0,0 +1,70 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_slength function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = 'discombobulate'
+ $two = 17
+ validate_slength($one,$two)
+ DOC
+ it 'validates a single string max' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = ['discombobulate', 'moo']
+ $two = 17
+ validate_slength($one,$two)
+ DOC
+ it 'validates multiple string maxes' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+
+ pp3 = <<-DOC
+ $one = ['discombobulate', 'moo']
+ $two = 17
+ $three = 3
+ validate_slength($one,$two,$three)
+ DOC
+ it 'validates min/max of strings in array' do
+ apply_manifest(pp3, :catch_failures => true)
+ end
+
+ pp4 = <<-DOC
+ $one = 'discombobulate'
+ $two = 1
+ validate_slength($one,$two)
+ DOC
+ it 'validates a single string max of incorrect length' do
+ apply_manifest(pp4, :expect_failures => true)
+ end
+
+ pp5 = <<-DOC
+ $one = ['discombobulate', 'moo']
+ $two = 3
+ validate_slength($one,$two)
+ DOC
+ it 'validates multiple string maxes of incorrect length' do
+ apply_manifest(pp5, :expect_failures => true)
+ end
+
+ pp6 = <<-DOC
+ $one = ['discombobulate', 'moo']
+ $two = 17
+ $three = 10
+ validate_slength($one,$two,$three)
+ DOC
+ it 'validates multiple strings min/maxes of incorrect length' do
+ apply_manifest(pp6, :expect_failures => true)
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ it 'handles improper first argument type'
+ it 'handles non-strings in array of first argument'
+ it 'handles improper second argument type'
+ it 'handles improper third argument type'
+ it 'handles negative ranges'
+ it 'handles improper ranges'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/validate_string_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/validate_string_spec.rb
new file mode 100644
index 0000000..d141f59
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/validate_string_spec.rb
@@ -0,0 +1,42 @@
+require 'spec_helper_acceptance'
+
+describe 'validate_string function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = 'string'
+ validate_string($one)
+ DOC
+ it 'validates a single argument' do
+ apply_manifest(pp1, :catch_failures => true)
+ end
+
+ pp2 = <<-DOC
+ $one = 'string'
+ $two = 'also string'
+ validate_string($one,$two)
+ DOC
+ it 'validates an multiple arguments' do
+ apply_manifest(pp2, :catch_failures => true)
+ end
+
+ pp3 = <<-DOC
+ validate_string(undef)
+ DOC
+ it 'validates undef' do
+ apply_manifest(pp3, :catch_failures => true)
+ end
+
+ {
+ %{validate_string({ 'a' => 'hash' })} => 'Hash',
+ %{validate_string(['array'])} => 'Array',
+ %{validate_string(false)} => 'FalseClass',
+ }.each do |pp4, type|
+ it "validates a non-string: #{pp4.inspect}" do
+ expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{a #{type}})
+ end
+ end
+ end
+ describe 'failure' do
+ it 'handles improper number of arguments'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/values_at_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/values_at_spec.rb
new file mode 100644
index 0000000..ffd6f4c
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/values_at_spec.rb
@@ -0,0 +1,71 @@
+require 'spec_helper_acceptance'
+
+describe 'values_at function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = ['a','b','c','d','e']
+ $two = 1
+ $output = values_at($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'returns a specific value' do
+ expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\["b"\]})
+ end
+
+ pp2 = <<-DOC
+ $one = ['a','b','c','d','e']
+ $two = -1
+ $output = values_at($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'returns a specific negative index value' do
+ pending("negative numbers don't work")
+ expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\["e"\]})
+ end
+
+ pp3 = <<-DOC
+ $one = ['a','b','c','d','e']
+ $two = "1-3"
+ $output = values_at($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'returns a range of values' do
+ expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\["b", "c", "d"\]})
+ end
+
+ pp4 = <<-DOC
+ $one = ['a','b','c','d','e']
+ $two = ["1-3",0]
+ $output = values_at($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'returns a negative specific value and range of values' do
+ expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\["b", "c", "d", "a"\]})
+ end
+ end
+
+ describe 'failure' do
+ pp5 = <<-DOC
+ $one = ['a','b','c','d','e']
+ $output = values_at($one)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'handles improper number of arguments' do
+ expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
+ end
+
+ pp6 = <<-DOC
+ $one = ['a','b','c','d','e']
+ $two = []
+ $output = values_at($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'handles non-indicies arguments' do
+ expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{at least one positive index})
+ end
+
+ it 'detects index ranges smaller than the start range'
+ it 'handles index ranges larger than array'
+ it 'handles non-integer indicies'
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/values_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/values_spec.rb
new file mode 100644
index 0000000..b450dc7
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/values_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper_acceptance'
+
+describe 'values function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
+ describe 'success' do
+ pp1 = <<-DOC
+ $arg = {
+ 'a' => 1,
+ 'b' => 2,
+ 'c' => 3,
+ }
+ $output = values($arg)
+ notice(inline_template('<%= @output.sort.inspect %>'))
+ DOC
+ it 'returns an array of values' do
+ expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[1, 2, 3\]})
+ end
+ end
+
+ describe 'failure' do
+ pp2 = <<-DOC
+ $arg = "foo"
+ $output = values($arg)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'handles non-hash arguments' do
+ expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash})
+ end
+ end
+end
diff --git a/code/environments/production/modules/stdlib/spec/acceptance/zip_spec.rb b/code/environments/production/modules/stdlib/spec/acceptance/zip_spec.rb
new file mode 100644
index 0000000..57adfa7
--- /dev/null
+++ b/code/environments/production/modules/stdlib/spec/acceptance/zip_spec.rb
@@ -0,0 +1,71 @@
+require 'spec_helper_acceptance'
+
+describe 'zip function' do
+ describe 'success' do
+ pp1 = <<-DOC
+ $one = [1,2,3,4]
+ $two = [5,6,7,8]
+ $output = zip($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'zips two arrays of numbers together' do
+ expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\], \[3, 7\], \[4, 8\]\]})
+ end
+
+ pp2 = <<-DOC
+ $one = [1,2,"three",4]
+ $two = [true,true,false,false]
+ $output = zip($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'zips two arrays of numbers & bools together' do
+ expect(apply_manifest(pp2, :catch_failures => true).stdout).to match(%r{\[\[1, true\], \[2, true\], \["three", false\], \[4, false\]\]})
+ end
+
+ # XXX This only tests the argument `true`, even though the following are valid:
+ # 1 t y true yes
+ # 0 f n false no
+ # undef undefined
+ pp3 = <<-DOC
+ $one = [1,2,3,4]
+ $two = [5,6,7,8]
+ $output = zip($one,$two,true)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'zips two arrays of numbers together and flattens them' do
+ expect(apply_manifest(pp3, :catch_failures => true).stdout).to match(%r{\[1, 5, 2, 6, 3, 7, 4, 8\]})
+ end
+
+ # XXX Is this expected behavior?
+ pp4 = <<-DOC
+ $one = [1,2]
+ $two = [5,6,7,8]
+ $output = zip($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'handles unmatched length' do
+ expect(apply_manifest(pp4, :catch_failures => true).stdout).to match(%r{\[\[1, 5\], \[2, 6\]\]})
+ end
+ end
+
+ describe 'failure' do
+ pp5 = <<-DOC
+ $one = [1,2]
+ $output = zip($one)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'handles improper number of arguments' do
+ expect(apply_manifest(pp5, :expect_failures => true).stderr).to match(%r{Wrong number of arguments})
+ end
+
+ pp6 = <<-DOC
+ $one = "a string"
+ $two = [5,6,7,8]
+ $output = zip($one,$two)
+ notice(inline_template('<%= @output.inspect %>'))
+ DOC
+ it 'handles improper argument types' do
+ expect(apply_manifest(pp6, :expect_failures => true).stderr).to match(%r{Requires array})
+ end
+ end
+end