Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / dos2unix_spec.rb
1 require 'spec_helper'
2
3 describe 'dos2unix' do
4   context 'when checking parameter validity' do
5     it { is_expected.not_to eq(nil) }
6     it do
7       is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Wrong number of arguments})
8     end
9     it do
10       is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{Wrong number of arguments})
11     end
12     it do
13       is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{Requires string as argument})
14     end
15     it do
16       is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires string as argument})
17     end
18     it do
19       is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires string as argument})
20     end
21   end
22
23   context 'when converting from dos to unix format' do
24     sample_text    = "Hello\r\nWorld\r\n"
25     desired_output = "Hello\nWorld\n"
26
27     it 'outputs unix format' do
28       is_expected.to run.with_params(sample_text).and_return(desired_output)
29     end
30   end
31
32   context 'with internationalization (i18N) values' do
33     sample_text_utf8    = "Ħ℮ļłǿ\r\nשׁөŕłđ\r\n"
34     desired_output_utf8 = "Ħ℮ļłǿ\nשׁөŕłđ\n"
35
36     sample_text_doublebyte    = "こんにちは\r\n世界\r\n"
37     desired_output_doublebyte = "こんにちは\n世界\n"
38
39     it 'outputs uft8 string' do
40       is_expected.to run.with_params(sample_text_utf8).and_return(desired_output_utf8)
41     end
42
43     it 'outputs double byte string' do
44       is_expected.to run.with_params(sample_text_doublebyte).and_return(desired_output_doublebyte)
45     end
46   end
47 end