validate_slength_spec.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. require 'spec_helper_acceptance'
  2. describe 'validate_slength function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $one = 'discombobulate'
  6. $two = 17
  7. validate_slength($one,$two)
  8. DOC
  9. it 'validates a single string max' do
  10. apply_manifest(pp1, :catch_failures => true)
  11. end
  12. pp2 = <<-DOC
  13. $one = ['discombobulate', 'moo']
  14. $two = 17
  15. validate_slength($one,$two)
  16. DOC
  17. it 'validates multiple string maxes' do
  18. apply_manifest(pp2, :catch_failures => true)
  19. end
  20. pp3 = <<-DOC
  21. $one = ['discombobulate', 'moo']
  22. $two = 17
  23. $three = 3
  24. validate_slength($one,$two,$three)
  25. DOC
  26. it 'validates min/max of strings in array' do
  27. apply_manifest(pp3, :catch_failures => true)
  28. end
  29. pp4 = <<-DOC
  30. $one = 'discombobulate'
  31. $two = 1
  32. validate_slength($one,$two)
  33. DOC
  34. it 'validates a single string max of incorrect length' do
  35. apply_manifest(pp4, :expect_failures => true)
  36. end
  37. pp5 = <<-DOC
  38. $one = ['discombobulate', 'moo']
  39. $two = 3
  40. validate_slength($one,$two)
  41. DOC
  42. it 'validates multiple string maxes of incorrect length' do
  43. apply_manifest(pp5, :expect_failures => true)
  44. end
  45. pp6 = <<-DOC
  46. $one = ['discombobulate', 'moo']
  47. $two = 17
  48. $three = 10
  49. validate_slength($one,$two,$three)
  50. DOC
  51. it 'validates multiple strings min/maxes of incorrect length' do
  52. apply_manifest(pp6, :expect_failures => true)
  53. end
  54. end
  55. describe 'failure' do
  56. it 'handles improper number of arguments'
  57. it 'handles improper first argument type'
  58. it 'handles non-strings in array of first argument'
  59. it 'handles improper second argument type'
  60. it 'handles improper third argument type'
  61. it 'handles negative ranges'
  62. it 'handles improper ranges'
  63. end
  64. end