has_key_spec.rb 961 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. require 'spec_helper_acceptance'
  2. describe 'has_key function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
  6. $b = 'bbb'
  7. $c = true
  8. $o = has_key($a,$b)
  9. if $o == $c {
  10. notify { 'output correct': }
  11. }
  12. DOC
  13. it 'has_keys in hashes' do
  14. apply_manifest(pp1, :catch_failures => true) do |r|
  15. expect(r.stdout).to match(%r{Notice: output correct})
  16. end
  17. end
  18. pp2 = <<-DOC
  19. $a = { 'aaa' => 'bbb','bbb' => 'ccc','ddd' => 'eee' }
  20. $b = 'ccc'
  21. $c = false
  22. $o = has_key($a,$b)
  23. if $o == $c {
  24. notify { 'output correct': }
  25. }
  26. DOC
  27. it 'has_keys not in hashes' do
  28. apply_manifest(pp2, :catch_failures => true) do |r|
  29. expect(r.stdout).to match(%r{Notice: output correct})
  30. end
  31. end
  32. end
  33. describe 'failure' do
  34. it 'handles improper argument counts'
  35. it 'handles non-hashes'
  36. end
  37. end