Added modules
This commit is contained in:
parent
c53c931217
commit
59ec520742
646 changed files with 35182 additions and 0 deletions
30
modules/stdlib/spec/acceptance/abs_spec.rb
Executable file
30
modules/stdlib/spec/acceptance/abs_spec.rb
Executable file
|
@ -0,0 +1,30 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'abs function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should accept a string' do
|
||||
pp = <<-EOS
|
||||
$input = '-34.56'
|
||||
$output = abs($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: 34.56/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should accept a float' do
|
||||
pp = <<-EOS
|
||||
$input = -34.56
|
||||
$output = abs($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: 34.56/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
49
modules/stdlib/spec/acceptance/any2array_spec.rb
Executable file
49
modules/stdlib/spec/acceptance/any2array_spec.rb
Executable file
|
@ -0,0 +1,49 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'any2array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should create an empty array' do
|
||||
pp = <<-EOS
|
||||
$input = ''
|
||||
$output = any2array($input)
|
||||
validate_array($output)
|
||||
notify { "Output: ${output}": }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: Output: /)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should leave arrays modified' do
|
||||
pp = <<-EOS
|
||||
$input = ['test', 'array']
|
||||
$output = any2array($input)
|
||||
validate_array($output)
|
||||
notify { "Output: ${output}": }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: Output: testarray/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should turn a hash into an array' do
|
||||
pp = <<-EOS
|
||||
$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}": }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: Output: testarray/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
18
modules/stdlib/spec/acceptance/base64_spec.rb
Executable file
18
modules/stdlib/spec/acceptance/base64_spec.rb
Executable file
|
@ -0,0 +1,18 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'base64 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should encode then decode a string' do
|
||||
pp = <<-EOS
|
||||
$encodestring = base64('encode', 'thestring')
|
||||
$decodestring = base64('decode', $encodestring)
|
||||
notify { $decodestring: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/thestring/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
34
modules/stdlib/spec/acceptance/bool2num_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/bool2num_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
['false', 'f', '0', 'n', 'no'].each do |bool|
|
||||
it 'should convert a given boolean, #{bool}, to 0' do
|
||||
pp = <<-EOS
|
||||
$input = #{bool}
|
||||
$output = bool2num($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: 0/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
['true', 't', '1', 'y', 'yes'].each do |bool|
|
||||
it 'should convert a given boolean, #{bool}, to 1' do
|
||||
pp = <<-EOS
|
||||
$input = #{bool}
|
||||
$output = bool2num($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: 1/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
83
modules/stdlib/spec/acceptance/build_csv.rb
Executable file
83
modules/stdlib/spec/acceptance/build_csv.rb
Executable file
|
@ -0,0 +1,83 @@
|
|||
#!/usr/bin/env ruby
|
||||
# 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_method :original_require, :require
|
||||
# rewrite require
|
||||
def require name
|
||||
original_require name if name != 'spec_helper_acceptance'
|
||||
end
|
||||
end
|
||||
UNSUPPORTED_PLATFORMS = []
|
||||
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")].collect 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.inject({}) do |memo,c|
|
||||
memo[c.description] = Hash.new
|
||||
memo[c.description]["groups"] = get_tests(c.children) unless c.children.empty?
|
||||
memo[c.description]["tests"] = c.examples.collect { |e|
|
||||
e.description unless e.pending?
|
||||
}.compact unless c.examples.empty?
|
||||
memo[c.description]["pending_tests"] = c.examples.collect { |e|
|
||||
e.description if e.pending?
|
||||
}.compact unless c.examples.empty?
|
||||
memo
|
||||
end
|
||||
end
|
||||
|
||||
def count_test_types_in(type,group)
|
||||
return 0 if group.nil?
|
||||
group.inject(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.collect do |function_name|
|
||||
if v = tests["#{function_name} function"]
|
||||
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
|
||||
sprintf("%-25s, %-9d, %-9d, %-9d", function_name,positive_tests,negative_tests,pending_tests)
|
||||
end.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
|
33
modules/stdlib/spec/acceptance/capitalize_spec.rb
Executable file
33
modules/stdlib/spec/acceptance/capitalize_spec.rb
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'capitalize function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should capitalize the first letter of a string' do
|
||||
pp = <<-EOS
|
||||
$input = 'this is a string'
|
||||
$output = capitalize($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: This is a string/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should capitalize the first letter of an array of strings' do
|
||||
pp = <<-EOS
|
||||
$input = ['this', 'is', 'a', 'string']
|
||||
$output = capitalize($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: This/)
|
||||
expect(r.stdout).to match(/Notice: Is/)
|
||||
expect(r.stdout).to match(/Notice: A/)
|
||||
expect(r.stdout).to match(/Notice: String/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
21
modules/stdlib/spec/acceptance/chomp_spec.rb
Executable file
21
modules/stdlib/spec/acceptance/chomp_spec.rb
Executable file
|
@ -0,0 +1,21 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'chomp function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should eat the newline' do
|
||||
pp = <<-EOS
|
||||
$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.")
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
45
modules/stdlib/spec/acceptance/chop_spec.rb
Executable file
45
modules/stdlib/spec/acceptance/chop_spec.rb
Executable file
|
@ -0,0 +1,45 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should eat the last character' do
|
||||
pp = <<-EOS
|
||||
$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.")
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
it 'should eat the last two characters of \r\n' do
|
||||
pp = <<-EOS
|
||||
$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.")
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
|
||||
it 'should not fail on empty strings' do
|
||||
pp = <<-EOS
|
||||
$input = ""
|
||||
$output = chop($input)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
18
modules/stdlib/spec/acceptance/concat_spec.rb
Executable file
18
modules/stdlib/spec/acceptance/concat_spec.rb
Executable file
|
@ -0,0 +1,18 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'concat function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should concat one array to another' do
|
||||
pp = <<-EOS
|
||||
$output = concat(['1','2','3'],['4','5','6'])
|
||||
validate_array($output)
|
||||
if size($output) != 6 {
|
||||
fail("${output} should have 6 elements.")
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
30
modules/stdlib/spec/acceptance/count_spec.rb
Executable file
30
modules/stdlib/spec/acceptance/count_spec.rb
Executable file
|
@ -0,0 +1,30 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'count function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should count elements in an array' do
|
||||
pp = <<-EOS
|
||||
$input = [1,2,3,4]
|
||||
$output = count($input)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: 4/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'should count elements in an array that match a second argument' do
|
||||
pp = <<-EOS
|
||||
$input = [1,1,1,2]
|
||||
$output = count($input, 1)
|
||||
notify { $output: }
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: 3/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
20
modules/stdlib/spec/acceptance/deep_merge_spec.rb
Executable file
20
modules/stdlib/spec/acceptance/deep_merge_spec.rb
Executable file
|
@ -0,0 +1,20 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'deep_merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should deep merge two hashes' do
|
||||
pp = <<-EOS
|
||||
$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.")
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
22
modules/stdlib/spec/acceptance/defined_with_params_spec.rb
Executable file
22
modules/stdlib/spec/acceptance/defined_with_params_spec.rb
Executable file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'defined_with_params function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should successfully notify' do
|
||||
pp = <<-EOS
|
||||
user { 'dan':
|
||||
ensure => present,
|
||||
}
|
||||
|
||||
if defined_with_params(User[dan], {'ensure' => 'present' }) {
|
||||
notify { 'User defined with ensure=>present': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: User defined with ensure=>present/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
modules/stdlib/spec/acceptance/delete_at_spec.rb
Executable file
19
modules/stdlib/spec/acceptance/delete_at_spec.rb
Executable file
|
@ -0,0 +1,19 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'delete_at function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should delete elements of the array' do
|
||||
pp = <<-EOS
|
||||
$output = delete_at(['a','b','c','b'], 1)
|
||||
if $output == ['a','c','b'] {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
modules/stdlib/spec/acceptance/delete_spec.rb
Executable file
19
modules/stdlib/spec/acceptance/delete_spec.rb
Executable file
|
@ -0,0 +1,19 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'delete function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should delete elements of the array' do
|
||||
pp = <<-EOS
|
||||
$output = delete(['a','b','c','b'], 'b')
|
||||
if $output == ['a','c'] {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
19
modules/stdlib/spec/acceptance/delete_undef_values_spec.rb
Executable file
19
modules/stdlib/spec/acceptance/delete_undef_values_spec.rb
Executable file
|
@ -0,0 +1,19 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'delete_undef_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should delete elements of the array' do
|
||||
pp = <<-EOS
|
||||
$output = delete_undef_values({a=>'A', b=>'', c=>undef, d => false})
|
||||
if $output == { a => 'A', b => '', d => false } {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
25
modules/stdlib/spec/acceptance/delete_values_spec.rb
Executable file
25
modules/stdlib/spec/acceptance/delete_values_spec.rb
Executable file
|
@ -0,0 +1,25 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'delete_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should delete elements of the hash' do
|
||||
pp = <<-EOS
|
||||
$a = { 'a' => 'A', 'b' => 'B', 'B' => 'C', 'd' => 'B' }
|
||||
$b = { 'a' => 'A', 'B' => 'C' }
|
||||
$o = delete_values($a, 'B')
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles non-hash arguments'
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
26
modules/stdlib/spec/acceptance/difference_spec.rb
Executable file
26
modules/stdlib/spec/acceptance/difference_spec.rb
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'difference function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'returns non-duplicates in the first array' do
|
||||
pp = <<-EOS
|
||||
$a = ['a','b','c']
|
||||
$b = ['b','c','d']
|
||||
$c = ['a']
|
||||
$o = difference($a, $b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles non-array arguments'
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
42
modules/stdlib/spec/acceptance/dirname_spec.rb
Executable file
42
modules/stdlib/spec/acceptance/dirname_spec.rb
Executable file
|
@ -0,0 +1,42 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'dirname function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
context 'absolute path' do
|
||||
it 'returns the dirname' do
|
||||
pp = <<-EOS
|
||||
$a = '/path/to/a/file.txt'
|
||||
$b = '/path/to/a'
|
||||
$o = dirname($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'relative path' do
|
||||
it 'returns the dirname' do
|
||||
pp = <<-EOS
|
||||
$a = 'path/to/a/file.txt'
|
||||
$b = 'path/to/a'
|
||||
$o = dirname($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
39
modules/stdlib/spec/acceptance/downcase_spec.rb
Executable file
39
modules/stdlib/spec/acceptance/downcase_spec.rb
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'downcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'returns the downcase' do
|
||||
pp = <<-EOS
|
||||
$a = 'AOEU'
|
||||
$b = 'aoeu'
|
||||
$o = downcase($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'doesn\'t affect lowercase words' do
|
||||
pp = <<-EOS
|
||||
$a = 'aoeu aoeu'
|
||||
$b = 'aoeu aoeu'
|
||||
$o = downcase($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-strings'
|
||||
end
|
||||
end
|
39
modules/stdlib/spec/acceptance/empty_spec.rb
Executable file
39
modules/stdlib/spec/acceptance/empty_spec.rb
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'empty function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'recognizes empty strings' do
|
||||
pp = <<-EOS
|
||||
$a = ''
|
||||
$b = true
|
||||
$o = empty($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'recognizes non-empty strings' do
|
||||
pp = <<-EOS
|
||||
$a = 'aoeu'
|
||||
$b = false
|
||||
$o = empty($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-strings'
|
||||
end
|
||||
end
|
24
modules/stdlib/spec/acceptance/ensure_packages_spec.rb
Executable file
24
modules/stdlib/spec/acceptance/ensure_packages_spec.rb
Executable file
|
@ -0,0 +1,24 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'ensure_packages function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'ensure_packages a package' do
|
||||
apply_manifest('package { "zsh": ensure => absent, }')
|
||||
pp = <<-EOS
|
||||
$a = "zsh"
|
||||
ensure_packages($a)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_changes => true) do |r|
|
||||
expect(r.stdout).to match(/Package\[zsh\]\/ensure: (created|ensure changed 'purged' to 'present')/)
|
||||
end
|
||||
end
|
||||
it 'ensures a package already declared'
|
||||
it 'takes defaults arguments'
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings'
|
||||
end
|
||||
end
|
24
modules/stdlib/spec/acceptance/ensure_resource_spec.rb
Executable file
24
modules/stdlib/spec/acceptance/ensure_resource_spec.rb
Executable file
|
@ -0,0 +1,24 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'ensure_resource function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'ensure_resource a package' do
|
||||
apply_manifest('package { "zsh": ensure => absent, }')
|
||||
pp = <<-EOS
|
||||
$a = "zsh"
|
||||
ensure_resource('package', $a)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_changes => true) do |r|
|
||||
expect(r.stdout).to match(/Package\[zsh\]\/ensure: created/)
|
||||
end
|
||||
end
|
||||
it 'ensures a resource already declared'
|
||||
it 'takes defaults arguments'
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings'
|
||||
end
|
||||
end
|
39
modules/stdlib/spec/acceptance/flatten_spec.rb
Executable file
39
modules/stdlib/spec/acceptance/flatten_spec.rb
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'flatten function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'flattens arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["a","b",["c",["d","e"],"f","g"]]
|
||||
$b = ["a","b","c","d","e","f","g"]
|
||||
$o = flatten($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'does not affect flat arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["a","b","c","d","e","f","g"]
|
||||
$b = ["a","b","c","d","e","f","g"]
|
||||
$o = flatten($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-strings'
|
||||
end
|
||||
end
|
39
modules/stdlib/spec/acceptance/floor_spec.rb
Executable file
39
modules/stdlib/spec/acceptance/floor_spec.rb
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'floor function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'floors floats' do
|
||||
pp = <<-EOS
|
||||
$a = 12.8
|
||||
$b = 12
|
||||
$o = floor($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'floors integers' do
|
||||
pp = <<-EOS
|
||||
$a = 7
|
||||
$b = 7
|
||||
$o = floor($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-numbers'
|
||||
end
|
||||
end
|
34
modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/fqdn_rotate_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'fqdn_rotate function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
let(:facts_d) do
|
||||
if fact('is_pe') == "true"
|
||||
'/etc/puppetlabs/facter/facts.d'
|
||||
else
|
||||
'/etc/facter/facts.d'
|
||||
end
|
||||
end
|
||||
after :each do
|
||||
shell("if [ -f #{facts_d}/fqdn.txt ] ; then rm #{facts_d}/fqdn.txt ; fi")
|
||||
end
|
||||
it 'fqdn_rotates floats' do
|
||||
shell("mkdir -p #{facts_d}")
|
||||
shell("echo 'fqdn=fakehost.localdomain' > #{facts_d}/fqdn.txt")
|
||||
pp = <<-EOS
|
||||
$a = ['a','b','c','d']
|
||||
$o = fqdn_rotate($a)
|
||||
notice(inline_template('fqdn_rotate is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/fqdn_rotate is \["c", "d", "a", "b"\]/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-numbers'
|
||||
end
|
||||
end
|
41
modules/stdlib/spec/acceptance/get_module_path_spec.rb
Executable file
41
modules/stdlib/spec/acceptance/get_module_path_spec.rb
Executable file
|
@ -0,0 +1,41 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'get_module_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'get_module_paths stdlib' do
|
||||
pp = <<-EOS
|
||||
$a = $::is_pe ? {
|
||||
'true' => '/opt/puppet/share/puppet/modules/stdlib',
|
||||
'false' => '/etc/puppet/modules/stdlib',
|
||||
}
|
||||
$o = get_module_path('stdlib')
|
||||
if $o == $a {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'get_module_paths dne' do
|
||||
pp = <<-EOS
|
||||
$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': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true)
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-numbers'
|
||||
end
|
||||
end
|
25
modules/stdlib/spec/acceptance/getparam_spec.rb
Executable file
25
modules/stdlib/spec/acceptance/getparam_spec.rb
Executable file
|
@ -0,0 +1,25 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'getparam function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'getparam a package' do
|
||||
pp = <<-EOS
|
||||
user { "rspec":
|
||||
ensure => present,
|
||||
managehome => true,
|
||||
}
|
||||
$o = getparam(User['rspec'], 'managehome')
|
||||
notice(inline_template('getparam is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/getparam is true/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings'
|
||||
end
|
||||
end
|
26
modules/stdlib/spec/acceptance/getvar_spec.rb
Executable file
26
modules/stdlib/spec/acceptance/getvar_spec.rb
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'getvar function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'getvars from classes' do
|
||||
pp = <<-EOS
|
||||
class a::data { $foo = 'aoeu' }
|
||||
include a::data
|
||||
$b = 'aoeu'
|
||||
$o = getvar("a::data::foo")
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-numbers'
|
||||
end
|
||||
end
|
26
modules/stdlib/spec/acceptance/grep_spec.rb
Executable file
26
modules/stdlib/spec/acceptance/grep_spec.rb
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'grep function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'greps arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaabbb','bbbccc','dddeee']
|
||||
$b = 'bbb'
|
||||
$c = ['aaabbb','bbbccc']
|
||||
$o = grep($a,$b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
44
modules/stdlib/spec/acceptance/has_interface_with_spec.rb
Executable file
44
modules/stdlib/spec/acceptance/has_interface_with_spec.rb
Executable file
|
@ -0,0 +1,44 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'has_interface_with function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'has_interface_with existing ipaddress' do
|
||||
pp = <<-EOS
|
||||
$a = '127.0.0.1'
|
||||
$o = has_interface_with('ipaddress', $a)
|
||||
notice(inline_template('has_interface_with is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_interface_with is true/)
|
||||
end
|
||||
end
|
||||
it 'has_interface_with absent ipaddress' do
|
||||
pp = <<-EOS
|
||||
$a = '128.0.0.1'
|
||||
$o = has_interface_with('ipaddress', $a)
|
||||
notice(inline_template('has_interface_with is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_interface_with is false/)
|
||||
end
|
||||
end
|
||||
it 'has_interface_with existing interface' do
|
||||
pp = <<-EOS
|
||||
$a = 'lo'
|
||||
$o = has_interface_with($a)
|
||||
notice(inline_template('has_interface_with is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_interface_with is true/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings'
|
||||
end
|
||||
end
|
33
modules/stdlib/spec/acceptance/has_ip_address_spec.rb
Executable file
33
modules/stdlib/spec/acceptance/has_ip_address_spec.rb
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'has_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'has_ip_address existing ipaddress' do
|
||||
pp = <<-EOS
|
||||
$a = '127.0.0.1'
|
||||
$o = has_ip_address($a)
|
||||
notice(inline_template('has_ip_address is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_ip_address is true/)
|
||||
end
|
||||
end
|
||||
it 'has_ip_address absent ipaddress' do
|
||||
pp = <<-EOS
|
||||
$a = '128.0.0.1'
|
||||
$o = has_ip_address($a)
|
||||
notice(inline_template('has_ip_address is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_ip_address is false/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings'
|
||||
end
|
||||
end
|
33
modules/stdlib/spec/acceptance/has_ip_network_spec.rb
Executable file
33
modules/stdlib/spec/acceptance/has_ip_network_spec.rb
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'has_ip_network function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'has_ip_network existing ipaddress' do
|
||||
pp = <<-EOS
|
||||
$a = '127.0.0.0'
|
||||
$o = has_ip_network($a)
|
||||
notice(inline_template('has_ip_network is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_ip_network is true/)
|
||||
end
|
||||
end
|
||||
it 'has_ip_network absent ipaddress' do
|
||||
pp = <<-EOS
|
||||
$a = '128.0.0.0'
|
||||
$o = has_ip_network($a)
|
||||
notice(inline_template('has_ip_network is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/has_ip_network is false/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings'
|
||||
end
|
||||
end
|
41
modules/stdlib/spec/acceptance/has_key_spec.rb
Executable file
41
modules/stdlib/spec/acceptance/has_key_spec.rb
Executable file
|
@ -0,0 +1,41 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'has_key function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'has_keys in hashes' do
|
||||
pp = <<-EOS
|
||||
$a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
|
||||
$b = 'bbb'
|
||||
$c = true
|
||||
$o = has_key($a,$b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'has_keys not in hashes' do
|
||||
pp = <<-EOS
|
||||
$a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
|
||||
$b = 'ccc'
|
||||
$c = false
|
||||
$o = has_key($a,$b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-hashes'
|
||||
end
|
||||
end
|
26
modules/stdlib/spec/acceptance/hash_spec.rb
Executable file
26
modules/stdlib/spec/acceptance/hash_spec.rb
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'hashs arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','bbb','ccc','ddd','eee']
|
||||
$b = { 'aaa' => 'bbb', 'bbb' => 'ccc', 'ddd' => 'eee' }
|
||||
$o = hash($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
27
modules/stdlib/spec/acceptance/intersection_spec.rb
Executable file
27
modules/stdlib/spec/acceptance/intersection_spec.rb
Executable file
|
@ -0,0 +1,27 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'intersection function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'intersections arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','ccc']
|
||||
$b = ['bbb','ccc','ddd','eee']
|
||||
$c = ['bbb','ccc']
|
||||
$o = intersection($a,$b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'intersections empty arrays'
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
67
modules/stdlib/spec/acceptance/is_array_spec.rb
Executable file
67
modules/stdlib/spec/acceptance/is_array_spec.rb
Executable file
|
@ -0,0 +1,67 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_arrays arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','ccc']
|
||||
$b = true
|
||||
$o = is_array($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_arrays empty arrays' do
|
||||
pp = <<-EOS
|
||||
$a = []
|
||||
$b = true
|
||||
$o = is_array($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_arrays strings' do
|
||||
pp = <<-EOS
|
||||
$a = "aoeu"
|
||||
$b = false
|
||||
$o = is_array($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_arrays hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'bbb'}
|
||||
$b = false
|
||||
$o = is_array($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
81
modules/stdlib/spec/acceptance/is_bool_spec.rb
Executable file
81
modules/stdlib/spec/acceptance/is_bool_spec.rb
Executable file
|
@ -0,0 +1,81 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_bools arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','ccc']
|
||||
$b = false
|
||||
$o = is_bool($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_bools true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$b = true
|
||||
$o = is_bool($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_bools false' do
|
||||
pp = <<-EOS
|
||||
$a = false
|
||||
$b = true
|
||||
$o = is_bool($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_bools strings' do
|
||||
pp = <<-EOS
|
||||
$a = "true"
|
||||
$b = false
|
||||
$o = is_bool($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_bools hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'bbb'}
|
||||
$b = false
|
||||
$o = is_bool($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
83
modules/stdlib/spec/acceptance/is_domain_name_spec.rb
Executable file
83
modules/stdlib/spec/acceptance/is_domain_name_spec.rb
Executable file
|
@ -0,0 +1,83 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_domain_name function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_domain_names arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa.com','bbb','ccc']
|
||||
$o = is_domain_name($a)
|
||||
notice(inline_template('is_domain_name is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_domain_name is false/)
|
||||
end
|
||||
end
|
||||
it 'is_domain_names true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$o = is_domain_name($a)
|
||||
notice(inline_template('is_domain_name is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_domain_name is false/)
|
||||
end
|
||||
end
|
||||
it 'is_domain_names false' do
|
||||
pp = <<-EOS
|
||||
$a = false
|
||||
$o = is_domain_name($a)
|
||||
notice(inline_template('is_domain_name is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_domain_name is false/)
|
||||
end
|
||||
end
|
||||
it 'is_domain_names strings with hyphens' do
|
||||
pp = <<-EOS
|
||||
$a = "3foo-bar.2bar-fuzz.com"
|
||||
$b = true
|
||||
$o = is_domain_name($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_domain_names strings beginning with hyphens' do
|
||||
pp = <<-EOS
|
||||
$a = "-bar.2bar-fuzz.com"
|
||||
$b = false
|
||||
$o = is_domain_name($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_domain_names hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'www.com'}
|
||||
$o = is_domain_name($a)
|
||||
notice(inline_template('is_domain_name is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_domain_name is false/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
86
modules/stdlib/spec/acceptance/is_float_spec.rb
Executable file
86
modules/stdlib/spec/acceptance/is_float_spec.rb
Executable file
|
@ -0,0 +1,86 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_float function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_floats arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa.com','bbb','ccc']
|
||||
$o = is_float($a)
|
||||
notice(inline_template('is_float is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_float is false/)
|
||||
end
|
||||
end
|
||||
it 'is_floats true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$o = is_float($a)
|
||||
notice(inline_template('is_float is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_float is false/)
|
||||
end
|
||||
end
|
||||
it 'is_floats strings' do
|
||||
pp = <<-EOS
|
||||
$a = "3.5"
|
||||
$b = true
|
||||
$o = is_float($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_floats floats' do
|
||||
pp = <<-EOS
|
||||
$a = 3.5
|
||||
$b = true
|
||||
$o = is_float($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_floats integers' do
|
||||
pp = <<-EOS
|
||||
$a = 3
|
||||
$b = false
|
||||
$o = is_float($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_floats hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'www.com'}
|
||||
$o = is_float($a)
|
||||
notice(inline_template('is_float is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_float is false/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
58
modules/stdlib/spec/acceptance/is_function_available_spec.rb
Executable file
58
modules/stdlib/spec/acceptance/is_function_available_spec.rb
Executable file
|
@ -0,0 +1,58 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_function_available function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_function_availables arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['fail','include','require']
|
||||
$o = is_function_available($a)
|
||||
notice(inline_template('is_function_available is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_function_available is false/)
|
||||
end
|
||||
end
|
||||
it 'is_function_availables true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$o = is_function_available($a)
|
||||
notice(inline_template('is_function_available is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_function_available is false/)
|
||||
end
|
||||
end
|
||||
it 'is_function_availables strings' do
|
||||
pp = <<-EOS
|
||||
$a = "fail"
|
||||
$b = true
|
||||
$o = is_function_available($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_function_availables function_availables' do
|
||||
pp = <<-EOS
|
||||
$a = "is_function_available"
|
||||
$o = is_function_available($a)
|
||||
notice(inline_template('is_function_available is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_function_available is true/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
63
modules/stdlib/spec/acceptance/is_hash_spec.rb
Executable file
63
modules/stdlib/spec/acceptance/is_hash_spec.rb
Executable file
|
@ -0,0 +1,63 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_hashs arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','ccc']
|
||||
$o = is_hash($a)
|
||||
notice(inline_template('is_hash is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_hash is false/)
|
||||
end
|
||||
end
|
||||
it 'is_hashs empty hashs' do
|
||||
pp = <<-EOS
|
||||
$a = {}
|
||||
$b = true
|
||||
$o = is_hash($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_hashs strings' do
|
||||
pp = <<-EOS
|
||||
$a = "aoeu"
|
||||
$b = false
|
||||
$o = is_hash($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_hashs hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'bbb'}
|
||||
$b = true
|
||||
$o = is_hash($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
95
modules/stdlib/spec/acceptance/is_integer_spec.rb
Executable file
95
modules/stdlib/spec/acceptance/is_integer_spec.rb
Executable file
|
@ -0,0 +1,95 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_integer function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_integers arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa.com','bbb','ccc']
|
||||
$b = false
|
||||
$o = is_integer($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_integers true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$b = false
|
||||
$o = is_integer($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_integers strings' do
|
||||
pp = <<-EOS
|
||||
$a = "3"
|
||||
$b = true
|
||||
$o = is_integer($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_integers floats' do
|
||||
pp = <<-EOS
|
||||
$a = 3.5
|
||||
$b = false
|
||||
$o = is_integer($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_integers integers' do
|
||||
pp = <<-EOS
|
||||
$a = 3
|
||||
$b = true
|
||||
$o = is_integer($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_integers hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'www.com'}
|
||||
$b = false
|
||||
$o = is_integer($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
80
modules/stdlib/spec/acceptance/is_ip_address_spec.rb
Executable file
80
modules/stdlib/spec/acceptance/is_ip_address_spec.rb
Executable file
|
@ -0,0 +1,80 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_ip_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_ip_addresss ipv4' do
|
||||
pp = <<-EOS
|
||||
$a = '1.2.3.4'
|
||||
$b = true
|
||||
$o = is_ip_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_ip_addresss ipv6' do
|
||||
pp = <<-EOS
|
||||
$a = "fe80:0000:cd12:d123:e2f8:47ff:fe09:dd74"
|
||||
$b = true
|
||||
$o = is_ip_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_ip_addresss ipv6 compressed' do
|
||||
pp = <<-EOS
|
||||
$a = "fe00::1"
|
||||
$b = true
|
||||
$o = is_ip_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_ip_addresss strings' do
|
||||
pp = <<-EOS
|
||||
$a = "aoeu"
|
||||
$b = false
|
||||
$o = is_ip_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_ip_addresss ipv4 out of range' do
|
||||
pp = <<-EOS
|
||||
$a = '1.2.3.400'
|
||||
$b = false
|
||||
$o = is_ip_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
38
modules/stdlib/spec/acceptance/is_mac_address_spec.rb
Executable file
38
modules/stdlib/spec/acceptance/is_mac_address_spec.rb
Executable file
|
@ -0,0 +1,38 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_mac_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_mac_addresss a mac' do
|
||||
pp = <<-EOS
|
||||
$a = '00:a0:1f:12:7f:a0'
|
||||
$b = true
|
||||
$o = is_mac_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_mac_addresss a mac out of range' do
|
||||
pp = <<-EOS
|
||||
$a = '00:a0:1f:12:7f:g0'
|
||||
$b = false
|
||||
$o = is_mac_address($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
95
modules/stdlib/spec/acceptance/is_numeric_spec.rb
Executable file
95
modules/stdlib/spec/acceptance/is_numeric_spec.rb
Executable file
|
@ -0,0 +1,95 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_numeric function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_numerics arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa.com','bbb','ccc']
|
||||
$b = false
|
||||
$o = is_numeric($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_numerics true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$b = false
|
||||
$o = is_numeric($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_numerics strings' do
|
||||
pp = <<-EOS
|
||||
$a = "3"
|
||||
$b = true
|
||||
$o = is_numeric($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_numerics floats' do
|
||||
pp = <<-EOS
|
||||
$a = 3.5
|
||||
$b = true
|
||||
$o = is_numeric($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_numerics integers' do
|
||||
pp = <<-EOS
|
||||
$a = 3
|
||||
$b = true
|
||||
$o = is_numeric($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_numerics hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'www.com'}
|
||||
$b = false
|
||||
$o = is_numeric($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
it 'handles non-arrays'
|
||||
end
|
||||
end
|
102
modules/stdlib/spec/acceptance/is_string_spec.rb
Executable file
102
modules/stdlib/spec/acceptance/is_string_spec.rb
Executable file
|
@ -0,0 +1,102 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'is_string function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'is_strings arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa.com','bbb','ccc']
|
||||
$b = false
|
||||
$o = is_string($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_strings true' do
|
||||
pp = <<-EOS
|
||||
$a = true
|
||||
$b = false
|
||||
$o = is_string($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_strings strings' do
|
||||
pp = <<-EOS
|
||||
$a = "aoeu"
|
||||
$o = is_string($a)
|
||||
notice(inline_template('is_string is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_string is true/)
|
||||
end
|
||||
end
|
||||
it 'is_strings number strings' do
|
||||
pp = <<-EOS
|
||||
$a = "3"
|
||||
$o = is_string($a)
|
||||
notice(inline_template('is_string is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/is_string is false/)
|
||||
end
|
||||
end
|
||||
it 'is_strings floats' do
|
||||
pp = <<-EOS
|
||||
$a = 3.5
|
||||
$b = false
|
||||
$o = is_string($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_strings integers' do
|
||||
pp = <<-EOS
|
||||
$a = 3
|
||||
$b = false
|
||||
$o = is_string($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'is_strings hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'www.com'}
|
||||
$b = false
|
||||
$o = is_string($a)
|
||||
if $o == $b {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
24
modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb
Executable file
24
modules/stdlib/spec/acceptance/join_keys_to_values_spec.rb
Executable file
|
@ -0,0 +1,24 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'join_keys_to_values function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'join_keys_to_valuess hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'bbb','ccc'=>'ddd'}
|
||||
$b = ':'
|
||||
$o = join_keys_to_values($a,$b)
|
||||
notice(inline_template('join_keys_to_values is <%= @o.sort.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
26
modules/stdlib/spec/acceptance/join_spec.rb
Executable file
26
modules/stdlib/spec/acceptance/join_spec.rb
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'join function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'joins arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','ccc']
|
||||
$b = ':'
|
||||
$c = 'aaa:bbb:ccc'
|
||||
$o = join($a,$b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'handles non arrays'
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
23
modules/stdlib/spec/acceptance/keys_spec.rb
Executable file
23
modules/stdlib/spec/acceptance/keys_spec.rb
Executable file
|
@ -0,0 +1,23 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'keys function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'keyss hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'aaa'=>'bbb','ccc'=>'ddd'}
|
||||
$o = keys($a)
|
||||
notice(inline_template('keys is <%= @o.sort.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
31
modules/stdlib/spec/acceptance/loadyaml_spec.rb
Normal file
31
modules/stdlib/spec/acceptance/loadyaml_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'loadyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'loadyamls array of values' do
|
||||
shell('echo "---
|
||||
aaa: 1
|
||||
bbb: 2
|
||||
ccc: 3
|
||||
ddd: 4" > /testyaml.yaml')
|
||||
pp = <<-EOS
|
||||
$o = loadyaml('/testyaml.yaml')
|
||||
notice(inline_template('loadyaml[aaa] is <%= @o["aaa"].inspect %>'))
|
||||
notice(inline_template('loadyaml[bbb] is <%= @o["bbb"].inspect %>'))
|
||||
notice(inline_template('loadyaml[ccc] is <%= @o["ccc"].inspect %>'))
|
||||
notice(inline_template('loadyaml[ddd] is <%= @o["ddd"].inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/loadyaml\[aaa\] is 1/)
|
||||
expect(r.stdout).to match(/loadyaml\[bbb\] is 2/)
|
||||
expect(r.stdout).to match(/loadyaml\[ccc\] is 3/)
|
||||
expect(r.stdout).to match(/loadyaml\[ddd\] is 4/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'fails with no arguments'
|
||||
end
|
||||
end
|
34
modules/stdlib/spec/acceptance/lstrip_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/lstrip_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'lstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'lstrips arrays' do
|
||||
pp = <<-EOS
|
||||
$a = [" the "," public "," art","galleries "]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = lstrip($a)
|
||||
notice(inline_template('lstrip is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/lstrip is \["the ", "public ", "art", "galleries "\]/)
|
||||
end
|
||||
end
|
||||
it 'lstrips strings' do
|
||||
pp = <<-EOS
|
||||
$a = " blowzy night-frumps vex'd jack q "
|
||||
$o = lstrip($a)
|
||||
notice(inline_template('lstrip is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
20
modules/stdlib/spec/acceptance/max_spec.rb
Executable file
20
modules/stdlib/spec/acceptance/max_spec.rb
Executable file
|
@ -0,0 +1,20 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'max function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'maxs arrays' do
|
||||
pp = <<-EOS
|
||||
$o = max("the","public","art","galleries")
|
||||
notice(inline_template('max is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/max is "the"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
end
|
||||
end
|
26
modules/stdlib/spec/acceptance/member_spec.rb
Executable file
26
modules/stdlib/spec/acceptance/member_spec.rb
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'members arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ['aaa','bbb','ccc']
|
||||
$b = 'ccc'
|
||||
$c = true
|
||||
$o = member($a,$b)
|
||||
if $o == $c {
|
||||
notify { 'output correct': }
|
||||
}
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/Notice: output correct/)
|
||||
end
|
||||
end
|
||||
it 'members arrays without members'
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper argument counts'
|
||||
end
|
||||
end
|
23
modules/stdlib/spec/acceptance/merge_spec.rb
Executable file
23
modules/stdlib/spec/acceptance/merge_spec.rb
Executable file
|
@ -0,0 +1,23 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'merge function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'should merge two hashes' do
|
||||
pp = <<-EOS
|
||||
$a = {'one' => 1, 'two' => 2, 'three' => { 'four' => 4 } }
|
||||
$b = {'two' => 'dos', 'three' => { 'five' => 5 } }
|
||||
$o = merge($a, $b)
|
||||
notice(inline_template('merge[one] is <%= @o["one"].inspect %>'))
|
||||
notice(inline_template('merge[two] is <%= @o["two"].inspect %>'))
|
||||
notice(inline_template('merge[three] is <%= @o["three"].inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/merge\[one\] is "1"/)
|
||||
expect(r.stdout).to match(/merge\[two\] is "dos"/)
|
||||
expect(r.stdout).to match(/merge\[three\] is {"five"=>"5"}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
20
modules/stdlib/spec/acceptance/min_spec.rb
Executable file
20
modules/stdlib/spec/acceptance/min_spec.rb
Executable file
|
@ -0,0 +1,20 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'min function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'mins arrays' do
|
||||
pp = <<-EOS
|
||||
$o = min("the","public","art","galleries")
|
||||
notice(inline_template('min is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/min is "art"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
end
|
||||
end
|
15
modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml
Normal file
15
modules/stdlib/spec/acceptance/nodesets/centos-6-vcloud.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
HOSTS:
|
||||
'centos-6-vcloud':
|
||||
roles:
|
||||
- master
|
||||
platform: el-6-x86_64
|
||||
hypervisor: vcloud
|
||||
template: centos-6-x86_64
|
||||
CONFIG:
|
||||
type: foss
|
||||
ssh:
|
||||
keys: "~/.ssh/id_rsa-acceptance"
|
||||
datastore: instance0
|
||||
folder: Delivery/Quality Assurance/Enterprise/Dynamic
|
||||
resourcepool: delivery/Quality Assurance/Enterprise/Dynamic
|
||||
pooling_api: http://vcloud.delivery.puppetlabs.net/
|
12
modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml
Normal file
12
modules/stdlib/spec/acceptance/nodesets/centos-64-x64-pe.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
HOSTS:
|
||||
centos-64-x64:
|
||||
roles:
|
||||
- master
|
||||
- database
|
||||
- dashboard
|
||||
platform: el-6-x86_64
|
||||
box : centos-64-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: pe
|
10
modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml
Normal file
10
modules/stdlib/spec/acceptance/nodesets/centos-64-x64.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
centos-64-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: el-6-x86_64
|
||||
box : centos-64-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: foss
|
10
modules/stdlib/spec/acceptance/nodesets/default.yml
Normal file
10
modules/stdlib/spec/acceptance/nodesets/default.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
centos-65-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: el-6-x86_64
|
||||
box : centos-65-x64-vbox436-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/centos-65-x64-virtualbox-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: foss
|
10
modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml
Normal file
10
modules/stdlib/spec/acceptance/nodesets/fedora-18-x64.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
fedora-18-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: fedora-18-x86_64
|
||||
box : fedora-18-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/fedora-18-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: foss
|
10
modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml
Normal file
10
modules/stdlib/spec/acceptance/nodesets/sles-11-x64.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
sles-11-x64.local:
|
||||
roles:
|
||||
- master
|
||||
platform: sles-11-x64
|
||||
box : sles-11sp1-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/sles-11sp1-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
ubuntu-server-10044-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-10.04-amd64
|
||||
box : ubuntu-server-10044-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-10044-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: foss
|
|
@ -0,0 +1,10 @@
|
|||
HOSTS:
|
||||
ubuntu-server-12042-x64:
|
||||
roles:
|
||||
- master
|
||||
platform: ubuntu-12.04-amd64
|
||||
box : ubuntu-server-12042-x64-vbox4210-nocm
|
||||
box_url : http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box
|
||||
hypervisor : vagrant
|
||||
CONFIG:
|
||||
type: foss
|
76
modules/stdlib/spec/acceptance/num2bool_spec.rb
Executable file
76
modules/stdlib/spec/acceptance/num2bool_spec.rb
Executable file
|
@ -0,0 +1,76 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'num2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'bools positive numbers and numeric strings as true' do
|
||||
pp = <<-EOS
|
||||
$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 %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/a is true/)
|
||||
expect(r.stdout).to match(/b is true/)
|
||||
expect(r.stdout).to match(/c is true/)
|
||||
end
|
||||
end
|
||||
it 'bools negative numbers as false' do
|
||||
pp = <<-EOS
|
||||
$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 %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/a is false/)
|
||||
expect(r.stdout).to match(/b is false/)
|
||||
expect(r.stdout).to match(/c is false/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'fails on words' do
|
||||
pp = <<-EOS
|
||||
$a = "a"
|
||||
$ao = num2bool($a)
|
||||
notice(inline_template('a is <%= @ao.inspect %>'))
|
||||
EOS
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/)
|
||||
end
|
||||
|
||||
it 'fails on numberwords' do
|
||||
pp = <<-EOS
|
||||
$b = "1b"
|
||||
$bo = num2bool($b)
|
||||
notice(inline_template('b is <%= @bo.inspect %>'))
|
||||
EOS
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/not look like a number/)
|
||||
|
||||
end
|
||||
|
||||
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?"
|
||||
pp = <<-EOS
|
||||
$c = {"c" => "-50"}
|
||||
$co = num2bool($c)
|
||||
notice(inline_template('c is <%= @co.inspect %>'))
|
||||
EOS
|
||||
expect(apply_manifest(ppc :expect_failures => true).stderr).to match(/Unable to parse/)
|
||||
end
|
||||
end
|
||||
end
|
34
modules/stdlib/spec/acceptance/parsejson_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/parsejson_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'parsejson function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'parses valid json' do
|
||||
pp = <<-EOS
|
||||
$a = '{"hunter": "washere", "tests": "passing"}'
|
||||
$ao = parsejson($a)
|
||||
$tests = $ao['tests']
|
||||
notice(inline_template('tests are <%= @tests.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/tests are "passing"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'raises error on incorrect json' do
|
||||
pp = <<-EOS
|
||||
$a = '{"hunter": "washere", "tests": "passing",}'
|
||||
$ao = parsejson($a)
|
||||
notice(inline_template('a is <%= @ao.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true) do |r|
|
||||
expect(r.stderr).to match(/expected next name/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'raises error on incorrect number of arguments'
|
||||
end
|
||||
end
|
35
modules/stdlib/spec/acceptance/parseyaml_spec.rb
Executable file
35
modules/stdlib/spec/acceptance/parseyaml_spec.rb
Executable file
|
@ -0,0 +1,35 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'parses valid yaml' do
|
||||
pp = <<-EOS
|
||||
$a = "---\nhunter: washere\ntests: passing\n"
|
||||
$o = parseyaml($a)
|
||||
$tests = $o['tests']
|
||||
notice(inline_template('tests are <%= @tests.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/tests are "passing"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'raises error on incorrect yaml' do
|
||||
pp = <<-EOS
|
||||
$a = "---\nhunter: washere\ntests: passing\n:"
|
||||
$o = parseyaml($a)
|
||||
$tests = $o['tests']
|
||||
notice(inline_template('tests are <%= @tests.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true) do |r|
|
||||
expect(r.stderr).to match(/(syntax error|did not find expected key)/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'raises error on incorrect number of arguments'
|
||||
end
|
||||
end
|
54
modules/stdlib/spec/acceptance/pick_default_spec.rb
Executable file
54
modules/stdlib/spec/acceptance/pick_default_spec.rb
Executable file
|
@ -0,0 +1,54 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'pick_default function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'pick_defaults a default value' do
|
||||
pp = <<-EOS
|
||||
$a = undef
|
||||
$o = pick_default($a, 'default')
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/picked is "default"/)
|
||||
end
|
||||
end
|
||||
it 'pick_defaults with no value' do
|
||||
pp = <<-EOS
|
||||
$a = undef
|
||||
$b = undef
|
||||
$o = pick_default($a,$b)
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/picked is ""/)
|
||||
end
|
||||
end
|
||||
it 'pick_defaults the first set value' do
|
||||
pp = <<-EOS
|
||||
$a = "something"
|
||||
$b = "long"
|
||||
$o = pick_default($a, $b, 'default')
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/picked is "something"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'raises error with no values' do
|
||||
pp = <<-EOS
|
||||
$o = pick_default()
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true) do |r|
|
||||
expect(r.stderr).to match(/Must receive at least one argument/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
44
modules/stdlib/spec/acceptance/pick_spec.rb
Executable file
44
modules/stdlib/spec/acceptance/pick_spec.rb
Executable file
|
@ -0,0 +1,44 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'pick function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'picks a default value' do
|
||||
pp = <<-EOS
|
||||
$a = undef
|
||||
$o = pick($a, 'default')
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/picked is "default"/)
|
||||
end
|
||||
end
|
||||
it 'picks the first set value' do
|
||||
pp = <<-EOS
|
||||
$a = "something"
|
||||
$b = "long"
|
||||
$o = pick($a, $b, 'default')
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/picked is "something"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'raises error with all undef values' do
|
||||
pp = <<-EOS
|
||||
$a = undef
|
||||
$b = undef
|
||||
$o = pick($a, $b)
|
||||
notice(inline_template('picked is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true) do |r|
|
||||
expect(r.stderr).to match(/must receive at least one non empty value/)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
42
modules/stdlib/spec/acceptance/prefix_spec.rb
Executable file
42
modules/stdlib/spec/acceptance/prefix_spec.rb
Executable file
|
@ -0,0 +1,42 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'prefix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'prefixes array of values' do
|
||||
pp = <<-EOS
|
||||
$o = prefix(['a','b','c'],'p')
|
||||
notice(inline_template('prefix is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/prefix is \["pa", "pb", "pc"\]/)
|
||||
end
|
||||
end
|
||||
it 'prefixs with empty array' do
|
||||
pp = <<-EOS
|
||||
$o = prefix([],'p')
|
||||
notice(inline_template('prefix is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/prefix is \[\]/)
|
||||
end
|
||||
end
|
||||
it 'prefixs array of values with undef' do
|
||||
pp = <<-EOS
|
||||
$o = prefix(['a','b','c'], undef)
|
||||
notice(inline_template('prefix is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
36
modules/stdlib/spec/acceptance/range_spec.rb
Executable file
36
modules/stdlib/spec/acceptance/range_spec.rb
Executable file
|
@ -0,0 +1,36 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'range function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'ranges letters' do
|
||||
pp = <<-EOS
|
||||
$o = range('a','d')
|
||||
notice(inline_template('range is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/range is \["a", "b", "c", "d"\]/)
|
||||
end
|
||||
end
|
||||
it 'ranges letters with a step' do
|
||||
pp = <<-EOS
|
||||
$o = range('a','d', '2')
|
||||
notice(inline_template('range is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
42
modules/stdlib/spec/acceptance/reject_spec.rb
Executable file
42
modules/stdlib/spec/acceptance/reject_spec.rb
Executable file
|
@ -0,0 +1,42 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'reject function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'rejects array of values' do
|
||||
pp = <<-EOS
|
||||
$o = reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
|
||||
notice(inline_template('reject is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/reject is \["bbb", "ccc"\]/)
|
||||
end
|
||||
end
|
||||
it 'rejects with empty array' do
|
||||
pp = <<-EOS
|
||||
$o = reject([],'aaa')
|
||||
notice(inline_template('reject is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/reject is \[\]/)
|
||||
end
|
||||
end
|
||||
it 'rejects array of values with undef' do
|
||||
pp = <<-EOS
|
||||
$o = reject(['aaa','bbb','ccc','aaaddd'], undef)
|
||||
notice(inline_template('reject is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
23
modules/stdlib/spec/acceptance/reverse_spec.rb
Executable file
23
modules/stdlib/spec/acceptance/reverse_spec.rb
Executable file
|
@ -0,0 +1,23 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'reverse function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'reverses strings' do
|
||||
pp = <<-EOS
|
||||
$a = "the public art galleries"
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = reverse($a)
|
||||
notice(inline_template('reverse is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/reverse is "seirellag tra cilbup eht"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings or arrays'
|
||||
end
|
||||
end
|
34
modules/stdlib/spec/acceptance/rstrip_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/rstrip_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'rstrip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'rstrips arrays' do
|
||||
pp = <<-EOS
|
||||
$a = [" the "," public "," art","galleries "]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = rstrip($a)
|
||||
notice(inline_template('rstrip is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/rstrip is \[" the", " public", " art", "galleries"\]/)
|
||||
end
|
||||
end
|
||||
it 'rstrips strings' do
|
||||
pp = <<-EOS
|
||||
$a = " blowzy night-frumps vex'd jack q "
|
||||
$o = rstrip($a)
|
||||
notice(inline_template('rstrip is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
34
modules/stdlib/spec/acceptance/shuffle_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/shuffle_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'shuffle function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'shuffles arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["1", "2", "3", "4", "5", "6", "7", "8", "the","public","art","galleries"]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = shuffle($a)
|
||||
notice(inline_template('shuffle is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to_not match(/shuffle is \["1", "2", "3", "4", "5", "6", "7", "8", "the", "public", "art", "galleries"\]/)
|
||||
end
|
||||
end
|
||||
it 'shuffles strings' do
|
||||
pp = <<-EOS
|
||||
$a = "blowzy night-frumps vex'd jack q"
|
||||
$o = shuffle($a)
|
||||
notice(inline_template('shuffle is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to_not match(/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
|
55
modules/stdlib/spec/acceptance/size_spec.rb
Executable file
55
modules/stdlib/spec/acceptance/size_spec.rb
Executable file
|
@ -0,0 +1,55 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'size function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'single string size' do
|
||||
pp = <<-EOS
|
||||
$a = 'discombobulate'
|
||||
$o = size($a)
|
||||
notice(inline_template('size is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/size is 14/)
|
||||
end
|
||||
end
|
||||
it 'with empty string' do
|
||||
pp = <<-EOS
|
||||
$a = ''
|
||||
$o = size($a)
|
||||
notice(inline_template('size is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/size is 0/)
|
||||
end
|
||||
end
|
||||
it 'with undef' do
|
||||
pp = <<-EOS
|
||||
$a = undef
|
||||
$o = size($a)
|
||||
notice(inline_template('size is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/size is 0/)
|
||||
end
|
||||
end
|
||||
it 'strings in array' do
|
||||
pp = <<-EOS
|
||||
$a = ['discombobulate', 'moo']
|
||||
$o = size($a)
|
||||
notice(inline_template('size is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/size is 2/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings or arrays'
|
||||
end
|
||||
end
|
34
modules/stdlib/spec/acceptance/sort_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/sort_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'sort function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'sorts arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["the","public","art","galleries"]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = sort($a)
|
||||
notice(inline_template('sort is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/sort is \["art", "galleries", "public", "the"\]/)
|
||||
end
|
||||
end
|
||||
it 'sorts strings' do
|
||||
pp = <<-EOS
|
||||
$a = "blowzy night-frumps vex'd jack q"
|
||||
$o = sort($a)
|
||||
notice(inline_template('sort is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/sort is " '-abcdefghijklmnopqrstuvwxyz"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings or arrays'
|
||||
end
|
||||
end
|
47
modules/stdlib/spec/acceptance/squeeze_spec.rb
Executable file
47
modules/stdlib/spec/acceptance/squeeze_spec.rb
Executable file
|
@ -0,0 +1,47 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'squeeze function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'squeezes arrays' do
|
||||
pp = <<-EOS
|
||||
# Real words!
|
||||
$a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
|
||||
$o = squeeze($a)
|
||||
notice(inline_template('squeeze is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/squeeze is \["wales", "laparohysterosalpingophorectomy", "br", "godeship"\]/)
|
||||
end
|
||||
end
|
||||
it 'squeezez arrays with an argument'
|
||||
it 'squeezes strings' do
|
||||
pp = <<-EOS
|
||||
$a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
|
||||
$o = squeeze($a)
|
||||
notice(inline_template('squeeze is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/squeeze is "wales laparohysterosalpingophorectomy br godeship"/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'squeezes strings with an argument' do
|
||||
pp = <<-EOS
|
||||
$a = "countessship duchessship governessship hostessship"
|
||||
$o = squeeze($a, 's')
|
||||
notice(inline_template('squeeze is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/squeeze is "counteship ducheship governeship hosteship"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings or arrays'
|
||||
end
|
||||
end
|
31
modules/stdlib/spec/acceptance/str2bool_spec.rb
Executable file
31
modules/stdlib/spec/acceptance/str2bool_spec.rb
Executable file
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'str2bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'works with "y"' do
|
||||
pp = <<-EOS
|
||||
$o = str2bool('y')
|
||||
notice(inline_template('str2bool is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
22
modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb
Executable file
22
modules/stdlib/spec/acceptance/str2saltedsha512_spec.rb
Executable file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'str2saltedsha512 function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'works with "y"' do
|
||||
pp = <<-EOS
|
||||
$o = str2saltedsha512('password')
|
||||
notice(inline_template('str2saltedsha512 is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
22
modules/stdlib/spec/acceptance/strftime_spec.rb
Executable file
22
modules/stdlib/spec/acceptance/strftime_spec.rb
Executable file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'strftime function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'gives the Century' do
|
||||
pp = <<-EOS
|
||||
$o = strftime('%C')
|
||||
notice(inline_template('strftime is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
34
modules/stdlib/spec/acceptance/strip_spec.rb
Executable file
34
modules/stdlib/spec/acceptance/strip_spec.rb
Executable file
|
@ -0,0 +1,34 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'strip function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'strips arrays' do
|
||||
pp = <<-EOS
|
||||
$a = [" the "," public "," art","galleries "]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = strip($a)
|
||||
notice(inline_template('strip is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/strip is \["the", "public", "art", "galleries"\]/)
|
||||
end
|
||||
end
|
||||
it 'strips strings' do
|
||||
pp = <<-EOS
|
||||
$a = " blowzy night-frumps vex'd jack q "
|
||||
$o = strip($a)
|
||||
notice(inline_template('strip is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
42
modules/stdlib/spec/acceptance/suffix_spec.rb
Executable file
42
modules/stdlib/spec/acceptance/suffix_spec.rb
Executable file
|
@ -0,0 +1,42 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'suffix function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'suffixes array of values' do
|
||||
pp = <<-EOS
|
||||
$o = suffix(['a','b','c'],'p')
|
||||
notice(inline_template('suffix is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/suffix is \["ap", "bp", "cp"\]/)
|
||||
end
|
||||
end
|
||||
it 'suffixs with empty array' do
|
||||
pp = <<-EOS
|
||||
$o = suffix([],'p')
|
||||
notice(inline_template('suffix is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/suffix is \[\]/)
|
||||
end
|
||||
end
|
||||
it 'suffixs array of values with undef' do
|
||||
pp = <<-EOS
|
||||
$o = suffix(['a','b','c'], undef)
|
||||
notice(inline_template('suffix is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
22
modules/stdlib/spec/acceptance/swapcase_spec.rb
Executable file
22
modules/stdlib/spec/acceptance/swapcase_spec.rb
Executable file
|
@ -0,0 +1,22 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'swapcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'works with strings' do
|
||||
pp = <<-EOS
|
||||
$o = swapcase('aBcD')
|
||||
notice(inline_template('swapcase is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
36
modules/stdlib/spec/acceptance/time_spec.rb
Executable file
36
modules/stdlib/spec/acceptance/time_spec.rb
Executable file
|
@ -0,0 +1,36 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'time function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'gives the time' do
|
||||
pp = <<-EOS
|
||||
$o = time()
|
||||
notice(inline_template('time is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
m = r.stdout.match(/time is (\d+)\D/)
|
||||
|
||||
# When I wrote this test
|
||||
expect(Integer(m[1])).to be > 1398894170
|
||||
end
|
||||
end
|
||||
it 'takes a timezone argument' do
|
||||
pp = <<-EOS
|
||||
$o = time('UTC')
|
||||
notice(inline_template('time is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
m = r.stdout.match(/time is (\d+)\D/)
|
||||
|
||||
expect(Integer(m[1])).to be > 1398894170
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles more arguments'
|
||||
it 'handles invalid timezones'
|
||||
end
|
||||
end
|
27
modules/stdlib/spec/acceptance/to_bytes_spec.rb
Executable file
27
modules/stdlib/spec/acceptance/to_bytes_spec.rb
Executable file
|
@ -0,0 +1,27 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'to_bytes function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'converts kB to B' do
|
||||
pp = <<-EOS
|
||||
$o = to_bytes('4 kB')
|
||||
notice(inline_template('to_bytes is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
m = r.stdout.match(/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
|
37
modules/stdlib/spec/acceptance/type_spec.rb
Executable file
37
modules/stdlib/spec/acceptance/type_spec.rb
Executable file
|
@ -0,0 +1,37 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'type function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'types arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["the","public","art","galleries"]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = type($a)
|
||||
notice(inline_template('type is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/type is "array"/)
|
||||
end
|
||||
end
|
||||
it 'types strings' do
|
||||
pp = <<-EOS
|
||||
$a = "blowzy night-frumps vex'd jack q"
|
||||
$o = type($a)
|
||||
notice(inline_template('type is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
24
modules/stdlib/spec/acceptance/union_spec.rb
Executable file
24
modules/stdlib/spec/acceptance/union_spec.rb
Executable file
|
@ -0,0 +1,24 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'union function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'unions arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["the","public"]
|
||||
$b = ["art","galleries"]
|
||||
# Anagram: Large picture halls, I bet
|
||||
$o = union($a,$b)
|
||||
notice(inline_template('union is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/union is \["the", "public", "art", "galleries"\]/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non arrays'
|
||||
end
|
||||
end
|
33
modules/stdlib/spec/acceptance/unique_spec.rb
Executable file
33
modules/stdlib/spec/acceptance/unique_spec.rb
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'unique function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'uniques arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["wallless", "wallless", "brrr", "goddessship"]
|
||||
$o = unique($a)
|
||||
notice(inline_template('unique is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/unique is \["wallless", "brrr", "goddessship"\]/)
|
||||
end
|
||||
end
|
||||
it 'uniques strings' do
|
||||
pp = <<-EOS
|
||||
$a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
|
||||
$o = unique($a)
|
||||
notice(inline_template('unique is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/unique is "wales prohytingcmbd"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings or arrays'
|
||||
end
|
||||
end
|
11
modules/stdlib/spec/acceptance/unsupported_spec.rb
Executable file
11
modules/stdlib/spec/acceptance/unsupported_spec.rb
Executable file
|
@ -0,0 +1,11 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'unsupported distributions and OSes', :if => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
it 'should fail' do
|
||||
pp = <<-EOS
|
||||
class { 'mysql::server': }
|
||||
EOS
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/unsupported osfamily/i)
|
||||
end
|
||||
end
|
33
modules/stdlib/spec/acceptance/upcase_spec.rb
Executable file
33
modules/stdlib/spec/acceptance/upcase_spec.rb
Executable file
|
@ -0,0 +1,33 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'upcase function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'upcases arrays' do
|
||||
pp = <<-EOS
|
||||
$a = ["wallless", "laparohysterosalpingooophorectomy", "brrr", "goddessship"]
|
||||
$o = upcase($a)
|
||||
notice(inline_template('upcase is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/upcase is \["WALLLESS", "LAPAROHYSTEROSALPINGOOOPHORECTOMY", "BRRR", "GODDESSSHIP"\]/)
|
||||
end
|
||||
end
|
||||
it 'upcases strings' do
|
||||
pp = <<-EOS
|
||||
$a = "wallless laparohysterosalpingooophorectomy brrr goddessship"
|
||||
$o = upcase($a)
|
||||
notice(inline_template('upcase is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/upcase is "WALLLESS LAPAROHYSTEROSALPINGOOOPHORECTOMY BRRR GODDESSSHIP"/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles no arguments'
|
||||
it 'handles non strings or arrays'
|
||||
end
|
||||
end
|
23
modules/stdlib/spec/acceptance/uriescape_spec.rb
Executable file
23
modules/stdlib/spec/acceptance/uriescape_spec.rb
Executable file
|
@ -0,0 +1,23 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'uriescape function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'uriescape strings' do
|
||||
pp = <<-EOS
|
||||
$a = ":/?#[]@!$&'()*+,;= \\\"{}"
|
||||
$o = uriescape($a)
|
||||
notice(inline_template('uriescape is <%= @o.inspect %>'))
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true) do |r|
|
||||
expect(r.stdout).to match(/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
|
31
modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb
Executable file
31
modules/stdlib/spec/acceptance/validate_absolute_path_spec.rb
Executable file
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_absolute_path function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) 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|
|
||||
it "validates a single argument #{path}" do
|
||||
pp = <<-EOS
|
||||
$one = '#{path}'
|
||||
validate_absolute_path($one)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
it 'handles relative paths'
|
||||
end
|
||||
end
|
37
modules/stdlib/spec/acceptance/validate_array_spec.rb
Executable file
37
modules/stdlib/spec/acceptance/validate_array_spec.rb
Executable file
|
@ -0,0 +1,37 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_array function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a single argument' do
|
||||
pp = <<-EOS
|
||||
$one = ['a', 'b']
|
||||
validate_array($one)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates an multiple arguments' do
|
||||
pp = <<-EOS
|
||||
$one = ['a', 'b']
|
||||
$two = [['c'], 'd']
|
||||
validate_array($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates a non-array' do
|
||||
{
|
||||
%{validate_array({'a' => 'hash' })} => "Hash",
|
||||
%{validate_array('string')} => "String",
|
||||
%{validate_array(false)} => "FalseClass",
|
||||
%{validate_array(undef)} => "String"
|
||||
}.each do |pp,type|
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
end
|
||||
end
|
63
modules/stdlib/spec/acceptance/validate_augeas_spec.rb
Executable file
63
modules/stdlib/spec/acceptance/validate_augeas_spec.rb
Executable file
|
@ -0,0 +1,63 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_augeas function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'prep' do
|
||||
it 'installs augeas for tests'
|
||||
end
|
||||
describe 'success' do
|
||||
context '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|
|
||||
it "validates a single argument for #{lens}" do
|
||||
pp = <<-EOS
|
||||
$line = "#{line}"
|
||||
$lens = "#{lens}"
|
||||
validate_augeas($line, $lens)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'valid inputs with 3rd and 4th arguments' do
|
||||
it "validates a restricted value" do
|
||||
line = 'root:x:0:0:root:/root:/bin/barsh\n'
|
||||
lens = 'Passwd.lns'
|
||||
restriction = '$file/*[shell="/bin/barsh"]'
|
||||
pp = <<-EOS
|
||||
$line = "#{line}"
|
||||
$lens = "#{lens}"
|
||||
$restriction = ['#{restriction}']
|
||||
validate_augeas($line, $lens, $restriction, "my custom failure message")
|
||||
EOS
|
||||
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/my custom failure message/)
|
||||
end
|
||||
end
|
||||
context 'invalid inputs' do
|
||||
{
|
||||
'root:x:0:0:root' => 'Passwd.lns',
|
||||
'127.0.1.1' => 'Hosts.lns'
|
||||
}.each do |line,lens|
|
||||
it "validates a single argument for #{lens}" do
|
||||
pp = <<-EOS
|
||||
$line = "#{line}"
|
||||
$lens = "#{lens}"
|
||||
validate_augeas($line, $lens)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
context 'garbage inputs' do
|
||||
it 'raises an error on invalid inputs'
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
end
|
||||
end
|
37
modules/stdlib/spec/acceptance/validate_bool_spec.rb
Executable file
37
modules/stdlib/spec/acceptance/validate_bool_spec.rb
Executable file
|
@ -0,0 +1,37 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_bool function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a single argument' do
|
||||
pp = <<-EOS
|
||||
$one = true
|
||||
validate_bool($one)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates an multiple arguments' do
|
||||
pp = <<-EOS
|
||||
$one = true
|
||||
$two = false
|
||||
validate_bool($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates a non-bool' do
|
||||
{
|
||||
%{validate_bool('true')} => "String",
|
||||
%{validate_bool('false')} => "String",
|
||||
%{validate_bool([true])} => "Array",
|
||||
%{validate_bool(undef)} => "String",
|
||||
}.each do |pp,type|
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
end
|
||||
end
|
50
modules/stdlib/spec/acceptance/validate_cmd_spec.rb
Executable file
50
modules/stdlib/spec/acceptance/validate_cmd_spec.rb
Executable file
|
@ -0,0 +1,50 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_cmd function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a true command' do
|
||||
pp = <<-EOS
|
||||
$one = 'foo'
|
||||
if $::osfamily == 'windows' {
|
||||
$two = 'echo' #shell built-in
|
||||
} else {
|
||||
$two = '/bin/echo'
|
||||
}
|
||||
validate_cmd($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates a fail command' do
|
||||
pp = <<-EOS
|
||||
$one = 'foo'
|
||||
if $::osfamily == 'windows' {
|
||||
$two = 'C:/aoeu'
|
||||
} else {
|
||||
$two = '/bin/aoeu'
|
||||
}
|
||||
validate_cmd($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true)
|
||||
end
|
||||
it 'validates a fail command with a custom error message' do
|
||||
pp = <<-EOS
|
||||
$one = 'foo'
|
||||
if $::osfamily == 'windows' {
|
||||
$two = 'C:/aoeu'
|
||||
} else {
|
||||
$two = '/bin/aoeu'
|
||||
}
|
||||
validate_cmd($one,$two,"aoeu is dvorak)
|
||||
EOS
|
||||
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/aoeu is dvorak/)
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
it 'handles improper argument types'
|
||||
end
|
||||
end
|
37
modules/stdlib/spec/acceptance/validate_hash_spec.rb
Executable file
37
modules/stdlib/spec/acceptance/validate_hash_spec.rb
Executable file
|
@ -0,0 +1,37 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_hash function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a single argument' do
|
||||
pp = <<-EOS
|
||||
$one = { 'a' => 1 }
|
||||
validate_hash($one)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates an multiple arguments' do
|
||||
pp = <<-EOS
|
||||
$one = { 'a' => 1 }
|
||||
$two = { 'b' => 2 }
|
||||
validate_hash($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates a non-hash' do
|
||||
{
|
||||
%{validate_hash('{ "not" => "hash" }')} => "String",
|
||||
%{validate_hash('string')} => "String",
|
||||
%{validate_hash(["array"])} => "Array",
|
||||
%{validate_hash(undef)} => "String",
|
||||
}.each do |pp,type|
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/a #{type}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
end
|
||||
end
|
31
modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb
Executable file
31
modules/stdlib/spec/acceptance/validate_ipv4_address_spec.rb
Executable file
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_ipv4_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a single argument' do
|
||||
pp = <<-EOS
|
||||
$one = '1.2.3.4'
|
||||
validate_ipv4_address($one)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates an multiple arguments' do
|
||||
pp = <<-EOS
|
||||
$one = '1.2.3.4'
|
||||
$two = '5.6.7.8'
|
||||
validate_ipv4_address($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :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
|
31
modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb
Executable file
31
modules/stdlib/spec/acceptance/validate_ipv6_address_spec.rb
Executable file
|
@ -0,0 +1,31 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_ipv6_address function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a single argument' do
|
||||
pp = <<-EOS
|
||||
$one = '3ffe:0505:0002::'
|
||||
validate_ipv6_address($one)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates an multiple arguments' do
|
||||
pp = <<-EOS
|
||||
$one = '3ffe:0505:0002::'
|
||||
$two = '3ffe:0505:0001::'
|
||||
validate_ipv6_address($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :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
|
47
modules/stdlib/spec/acceptance/validate_re_spec.rb
Executable file
47
modules/stdlib/spec/acceptance/validate_re_spec.rb
Executable file
|
@ -0,0 +1,47 @@
|
|||
#! /usr/bin/env ruby -S rspec
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
describe 'validate_re function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
||||
describe 'success' do
|
||||
it 'validates a string' do
|
||||
pp = <<-EOS
|
||||
$one = 'one'
|
||||
$two = '^one$'
|
||||
validate_re($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates an array' do
|
||||
pp = <<-EOS
|
||||
$one = 'one'
|
||||
$two = ['^one$', '^two']
|
||||
validate_re($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :catch_failures => true)
|
||||
end
|
||||
it 'validates a failed array' do
|
||||
pp = <<-EOS
|
||||
$one = 'one'
|
||||
$two = ['^two$', '^three']
|
||||
validate_re($one,$two)
|
||||
EOS
|
||||
|
||||
apply_manifest(pp, :expect_failures => true)
|
||||
end
|
||||
it 'validates a failed array with a custom error message' do
|
||||
pp = <<-EOS
|
||||
$one = '3.4.3'
|
||||
$two = '^2.7'
|
||||
validate_re($one,$two,"The $puppetversion fact does not match 2.7")
|
||||
EOS
|
||||
|
||||
expect(apply_manifest(pp, :expect_failures => true).stderr).to match(/does not match/)
|
||||
end
|
||||
end
|
||||
describe 'failure' do
|
||||
it 'handles improper number of arguments'
|
||||
it 'handles improper argument types'
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue