validate_cmd_spec.rb 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. require 'spec_helper_acceptance'
  2. describe 'validate_cmd function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $one = 'foo'
  6. if $::osfamily == 'windows' {
  7. $two = 'echo' #shell built-in
  8. } else {
  9. $two = '/bin/echo'
  10. }
  11. validate_cmd($one,$two)
  12. DOC
  13. it 'validates a true command' do
  14. apply_manifest(pp1, :catch_failures => true)
  15. end
  16. pp2 = <<-DOC
  17. $one = 'foo'
  18. if $::osfamily == 'windows' {
  19. $two = 'C:/aoeu'
  20. } else {
  21. $two = '/bin/aoeu'
  22. }
  23. validate_cmd($one,$two)
  24. DOC
  25. it 'validates a fail command' do
  26. apply_manifest(pp2, :expect_failures => true)
  27. end
  28. pp3 = <<-DOC
  29. $one = 'foo'
  30. if $::osfamily == 'windows' {
  31. $two = 'C:/aoeu'
  32. } else {
  33. $two = '/bin/aoeu'
  34. }
  35. validate_cmd($one,$two,"aoeu is dvorak")
  36. DOC
  37. it 'validates a fail command with a custom error message' do
  38. apply_manifest(pp3, :expect_failures => true) do |output|
  39. expect(output.stderr).to match(%r{aoeu is dvorak})
  40. end
  41. end
  42. end
  43. describe 'failure' do
  44. it 'handles improper number of arguments'
  45. it 'handles improper argument types'
  46. end
  47. end