flatten_spec.rb 1009 B

12345678910111213141516171819202122232425262728293031323334353637
  1. require 'spec_helper_acceptance'
  2. describe 'flatten function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $a = ["a","b",["c",["d","e"],"f","g"]]
  6. $b = ["a","b","c","d","e","f","g"]
  7. $o = flatten($a)
  8. if $o == $b {
  9. notify { 'output correct': }
  10. }
  11. DOC
  12. it 'flattens arrays' do
  13. apply_manifest(pp1, :catch_failures => true) do |r|
  14. expect(r.stdout).to match(%r{Notice: output correct})
  15. end
  16. end
  17. pp2 = <<-DOC
  18. $a = ["a","b","c","d","e","f","g"]
  19. $b = ["a","b","c","d","e","f","g"]
  20. $o = flatten($a)
  21. if $o == $b {
  22. notify { 'output correct': }
  23. }
  24. DOC
  25. it 'does not affect flat arrays' do
  26. apply_manifest(pp2, :catch_failures => true) do |r|
  27. expect(r.stdout).to match(%r{Notice: output correct})
  28. end
  29. end
  30. end
  31. describe 'failure' do
  32. it 'handles improper argument counts'
  33. it 'handles non-strings'
  34. end
  35. end