is_integer_spec.rb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. require 'spec_helper_acceptance'
  2. describe 'is_integer function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $a = ['aaa.com','bbb','ccc']
  6. $b = false
  7. $o = is_integer($a)
  8. if $o == $b {
  9. notify { 'output correct': }
  10. }
  11. DOC
  12. it 'is_integers 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 = true
  19. $b = false
  20. $o = is_integer($a)
  21. if $o == $b {
  22. notify { 'output correct': }
  23. }
  24. DOC
  25. it 'is_integers true' 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 = "3"
  32. $b = true
  33. $o = is_integer($a)
  34. if $o == $b {
  35. notify { 'output correct': }
  36. }
  37. DOC
  38. it 'is_integers strings' 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. pp4 = <<-DOC
  44. $a = 3.5
  45. $b = false
  46. $o = is_integer($a)
  47. if $o == $b {
  48. notify { 'output correct': }
  49. }
  50. DOC
  51. it 'is_integers floats' do
  52. apply_manifest(pp4, :catch_failures => true) do |r|
  53. expect(r.stdout).to match(%r{Notice: output correct})
  54. end
  55. end
  56. pp5 = <<-DOC
  57. $a = 3
  58. $b = true
  59. $o = is_integer($a)
  60. if $o == $b {
  61. notify { 'output correct': }
  62. }
  63. DOC
  64. it 'is_integers integers' do
  65. apply_manifest(pp5, :catch_failures => true) do |r|
  66. expect(r.stdout).to match(%r{Notice: output correct})
  67. end
  68. end
  69. pp6 = <<-DOC
  70. $a = {'aaa'=>'www.com'}
  71. $b = false
  72. $o = is_integer($a)
  73. if $o == $b {
  74. notify { 'output correct': }
  75. }
  76. DOC
  77. it 'is_integers hashes' do
  78. apply_manifest(pp6, :catch_failures => true) do |r|
  79. expect(r.stdout).to match(%r{Notice: output correct})
  80. end
  81. end
  82. end
  83. describe 'failure' do
  84. it 'handles improper argument counts'
  85. it 'handles non-arrays'
  86. end
  87. end