validate_re_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. require 'spec_helper_acceptance'
  2. describe 'validate_re function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $one = 'one'
  6. $two = '^one$'
  7. validate_re($one,$two)
  8. DOC
  9. it 'validates a string' do
  10. apply_manifest(pp1, :catch_failures => true)
  11. end
  12. pp2 = <<-DOC
  13. $one = 'one'
  14. $two = ['^one$', '^two']
  15. validate_re($one,$two)
  16. DOC
  17. it 'validates an array' do
  18. apply_manifest(pp2, :catch_failures => true)
  19. end
  20. pp3 = <<-DOC
  21. $one = 'one'
  22. $two = ['^two$', '^three']
  23. validate_re($one,$two)
  24. DOC
  25. it 'validates a failed array' do
  26. apply_manifest(pp3, :expect_failures => true)
  27. end
  28. pp4 = <<-DOC
  29. $one = '3.4.3'
  30. $two = '^2.7'
  31. validate_re($one,$two,"The $puppetversion fact does not match 2.7")
  32. DOC
  33. it 'validates a failed array with a custom error message' do
  34. expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{does not match})
  35. end
  36. end
  37. describe 'failure' do
  38. it 'handles improper number of arguments'
  39. it 'handles improper argument types'
  40. end
  41. end