is_hash_spec.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. require 'spec_helper_acceptance'
  2. describe 'is_hash function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $a = ['aaa','bbb','ccc']
  6. $o = is_hash($a)
  7. notice(inline_template('is_hash is <%= @o.inspect %>'))
  8. DOC
  9. it 'is_hashs arrays' do
  10. apply_manifest(pp1, :catch_failures => true) do |r|
  11. expect(r.stdout).to match(%r{is_hash is false})
  12. end
  13. end
  14. pp2 = <<-DOC
  15. $a = {}
  16. $b = true
  17. $o = is_hash($a)
  18. if $o == $b {
  19. notify { 'output correct': }
  20. }
  21. DOC
  22. it 'is_hashs empty hashs' do
  23. apply_manifest(pp2, :catch_failures => true) do |r|
  24. expect(r.stdout).to match(%r{Notice: output correct})
  25. end
  26. end
  27. pp3 = <<-DOC
  28. $a = "aoeu"
  29. $b = false
  30. $o = is_hash($a)
  31. if $o == $b {
  32. notify { 'output correct': }
  33. }
  34. DOC
  35. it 'is_hashs strings' do
  36. apply_manifest(pp3, :catch_failures => true) do |r|
  37. expect(r.stdout).to match(%r{Notice: output correct})
  38. end
  39. end
  40. pp4 = <<-DOC
  41. $a = {'aaa'=>'bbb'}
  42. $b = true
  43. $o = is_hash($a)
  44. if $o == $b {
  45. notify { 'output correct': }
  46. }
  47. DOC
  48. it 'is_hashs hashes' do
  49. apply_manifest(pp4, :catch_failures => true) do |r|
  50. expect(r.stdout).to match(%r{Notice: output correct})
  51. end
  52. end
  53. end
  54. describe 'failure' do
  55. it 'handles improper argument counts'
  56. end
  57. end