Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / chomp_spec.rb
1 require 'spec_helper'
2
3 describe 'chomp', :if => Puppet::Util::Package.versioncmp(Puppet.version, '6.0.0') < 0 do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments given}) }
6   it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string}) }
7   it {
8     pending('Current implementation ignores parameters after the first.')
9     is_expected.to run.with_params('a', 'b').and_raise_error(Puppet::ParseError)
10   }
11   it { is_expected.to run.with_params('one').and_return('one') }
12   it { is_expected.to run.with_params("one\n").and_return('one') }
13   it { is_expected.to run.with_params("one\n\n").and_return("one\n") }
14   it { is_expected.to run.with_params(["one\n", 'two', "three\n"]).and_return(['one', 'two', 'three']) }
15
16   it { is_expected.to run.with_params(AlsoString.new('one')).and_return('one') }
17   it { is_expected.to run.with_params(AlsoString.new("one\n")).and_return('one') }
18   it { is_expected.to run.with_params(AlsoString.new("one\n\n")).and_return("one\n") }
19   it { is_expected.to run.with_params([AlsoString.new("one\n"), AlsoString.new('two'), "three\n"]).and_return(['one', 'two', 'three']) }
20
21   it { is_expected.to run.with_params([1, 2, 3]).and_return([1, 2, 3]) }
22
23   context 'with UTF8 and double byte characters' do
24     it { is_expected.to run.with_params("ůťƒ8\n\n").and_return("ůťƒ8\n") }
25     it { is_expected.to run.with_params("ネット\n\n").and_return("ネット\n") }
26   end
27 end