dirname_spec.rb 989 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. require 'spec_helper_acceptance'
  2. describe 'dirname function' do
  3. describe 'success' do
  4. context 'with absolute path' do
  5. pp1 = <<-DOC
  6. $a = '/path/to/a/file.txt'
  7. $b = '/path/to/a'
  8. $o = dirname($a)
  9. if $o == $b {
  10. notify { 'output correct': }
  11. }
  12. DOC
  13. it 'returns the dirname' do
  14. apply_manifest(pp1, :catch_failures => true) do |r|
  15. expect(r.stdout).to match(%r{Notice: output correct})
  16. end
  17. end
  18. end
  19. context 'with relative path' do
  20. pp2 = <<-DOC
  21. $a = 'path/to/a/file.txt'
  22. $b = 'path/to/a'
  23. $o = dirname($a)
  24. if $o == $b {
  25. notify { 'output correct': }
  26. }
  27. DOC
  28. it 'returns the dirname' do
  29. apply_manifest(pp2, :catch_failures => true) do |r|
  30. expect(r.stdout).to match(%r{Notice: output correct})
  31. end
  32. end
  33. end
  34. end
  35. describe 'failure' do
  36. it 'handles improper argument counts'
  37. end
  38. end