37
|
1 #! /usr/bin/env ruby -S rspec
|
|
2 require 'spec_helper_acceptance'
|
|
3
|
|
4 describe 'chop function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
|
|
5 describe 'success' do
|
|
6 it 'should eat the last character' do
|
|
7 pp = <<-EOS
|
|
8 $input = "test"
|
|
9 if size($input) != 4 {
|
|
10 fail("Size of ${input} is not 4.")
|
|
11 }
|
|
12 $output = chop($input)
|
|
13 if size($output) != 3 {
|
|
14 fail("Size of ${input} is not 3.")
|
|
15 }
|
|
16 EOS
|
|
17
|
|
18 apply_manifest(pp, :catch_failures => true)
|
|
19 end
|
|
20
|
|
21 it 'should eat the last two characters of \r\n' do
|
|
22 pp = <<-'EOS'
|
|
23 $input = "test\r\n"
|
|
24 if size($input) != 6 {
|
|
25 fail("Size of ${input} is not 6.")
|
|
26 }
|
|
27 $output = chop($input)
|
|
28 if size($output) != 4 {
|
|
29 fail("Size of ${input} is not 4.")
|
|
30 }
|
|
31 EOS
|
|
32
|
|
33 apply_manifest(pp, :catch_failures => true)
|
|
34 end
|
|
35
|
|
36 it 'should not fail on empty strings' do
|
|
37 pp = <<-EOS
|
|
38 $input = ""
|
|
39 $output = chop($input)
|
|
40 EOS
|
|
41
|
|
42 apply_manifest(pp, :catch_failures => true)
|
|
43 end
|
|
44 end
|
|
45 end
|