empty_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. require 'spec_helper_acceptance'
  2. describe 'empty function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $a = ''
  6. $b = true
  7. $o = empty($a)
  8. if $o == $b {
  9. notify { 'output correct': }
  10. }
  11. DOC
  12. it 'recognizes empty strings' 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 = 'aoeu'
  19. $b = false
  20. $o = empty($a)
  21. if $o == $b {
  22. notify { 'output correct': }
  23. }
  24. DOC
  25. it 'recognizes non-empty strings' 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. pp3 = <<-DOC
  31. $a = 7
  32. $b = false
  33. $o = empty($a)
  34. if $o == $b {
  35. notify { 'output correct': }
  36. }
  37. DOC
  38. it 'handles numerical values' do
  39. apply_manifest(pp3, :catch_failures => true) do |r|
  40. expect(r.stdout).to match(%r{Notice: output correct})
  41. end
  42. end
  43. end
  44. describe 'failure' do
  45. it 'handles improper argument counts'
  46. it 'handles non-strings'
  47. end
  48. end