validate_string_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. require 'spec_helper_acceptance'
  2. describe 'validate_string function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $one = 'string'
  6. validate_string($one)
  7. DOC
  8. it 'validates a single argument' do
  9. apply_manifest(pp1, :catch_failures => true)
  10. end
  11. pp2 = <<-DOC
  12. $one = 'string'
  13. $two = 'also string'
  14. validate_string($one,$two)
  15. DOC
  16. it 'validates an multiple arguments' do
  17. apply_manifest(pp2, :catch_failures => true)
  18. end
  19. pp3 = <<-DOC
  20. validate_string(undef)
  21. DOC
  22. it 'validates undef' do
  23. apply_manifest(pp3, :catch_failures => true)
  24. end
  25. {
  26. %{validate_string({ 'a' => 'hash' })} => 'Hash',
  27. %{validate_string(['array'])} => 'Array',
  28. %{validate_string(false)} => 'FalseClass',
  29. }.each do |pp4, type|
  30. it "validates a non-string: #{pp4.inspect}" do
  31. expect(apply_manifest(pp4, :expect_failures => true).stderr).to match(%r{a #{type}})
  32. end
  33. end
  34. end
  35. describe 'failure' do
  36. it 'handles improper number of arguments'
  37. end
  38. end