chop_spec.rb 955 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. require 'spec_helper_acceptance'
  2. describe 'chop function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $input = "test"
  6. if size($input) != 4 {
  7. fail("Size of ${input} is not 4.")
  8. }
  9. $output = chop($input)
  10. if size($output) != 3 {
  11. fail("Size of ${input} is not 3.")
  12. }
  13. DOC
  14. it 'eats the last character' do
  15. apply_manifest(pp1, :catch_failures => true)
  16. end
  17. pp2 = <<-'DOC'
  18. $input = "test\r\n"
  19. if size($input) != 6 {
  20. fail("Size of ${input} is not 6.")
  21. }
  22. $output = chop($input)
  23. if size($output) != 4 {
  24. fail("Size of ${input} is not 4.")
  25. }
  26. DOC
  27. it 'eats the last two characters of \r\n' do
  28. apply_manifest(pp2, :catch_failures => true)
  29. end
  30. pp3 = <<-DOC
  31. $input = ""
  32. $output = chop($input)
  33. DOC
  34. it 'does not fail on empty strings' do
  35. apply_manifest(pp3, :catch_failures => true)
  36. end
  37. end
  38. end