is_string_spec.rb 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. require 'spec_helper_acceptance'
  2. describe 'is_string function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $a = ['aaa.com','bbb','ccc']
  6. $b = false
  7. $o = is_string($a)
  8. if $o == $b {
  9. notify { 'output correct': }
  10. }
  11. DOC
  12. it 'is_strings 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_string($a)
  21. if $o == $b {
  22. notify { 'output correct': }
  23. }
  24. DOC
  25. it 'is_strings 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 = "aoeu"
  32. $o = is_string($a)
  33. notice(inline_template('is_string is <%= @o.inspect %>'))
  34. DOC
  35. it 'is_strings strings' do
  36. apply_manifest(pp3, :catch_failures => true) do |r|
  37. expect(r.stdout).to match(%r{is_string is true})
  38. end
  39. end
  40. pp4 = <<-DOC
  41. $a = "3"
  42. $o = is_string($a)
  43. notice(inline_template('is_string is <%= @o.inspect %>'))
  44. DOC
  45. it 'is_strings number strings' do
  46. apply_manifest(pp4, :catch_failures => true) do |r|
  47. expect(r.stdout).to match(%r{is_string is false})
  48. end
  49. end
  50. pp5 = <<-DOC
  51. $a = 3.5
  52. $b = false
  53. $o = is_string($a)
  54. if $o == $b {
  55. notify { 'output correct': }
  56. }
  57. DOC
  58. it 'is_strings floats' do
  59. apply_manifest(pp5, :catch_failures => true) do |r|
  60. expect(r.stdout).to match(%r{Notice: output correct})
  61. end
  62. end
  63. pp6 = <<-DOC
  64. $a = 3
  65. $b = false
  66. $o = is_string($a)
  67. if $o == $b {
  68. notify { 'output correct': }
  69. }
  70. DOC
  71. it 'is_strings integers' do
  72. apply_manifest(pp6, :catch_failures => true) do |r|
  73. expect(r.stdout).to match(%r{Notice: output correct})
  74. end
  75. end
  76. pp7 = <<-DOC
  77. $a = {'aaa'=>'www.com'}
  78. $b = false
  79. $o = is_string($a)
  80. if $o == $b {
  81. notify { 'output correct': }
  82. }
  83. DOC
  84. it 'is_strings hashes' do
  85. apply_manifest(pp7, :catch_failures => true) do |r|
  86. expect(r.stdout).to match(%r{Notice: output correct})
  87. end
  88. end
  89. pp8 = <<-DOC
  90. $a = undef
  91. $o = is_string($a)
  92. notice(inline_template('is_string is <%= @o.inspect %>'))
  93. DOC
  94. it 'is_strings undef' do
  95. apply_manifest(pp8, :catch_failures => true) do |r|
  96. expect(r.stdout).to match(%r{is_string is true})
  97. end
  98. end
  99. end
  100. describe 'failure' do
  101. it 'handles improper argument counts'
  102. end
  103. end