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}i) }
6 it { is_expected.to run.with_params('', '', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
7 it { is_expected.to run.with_params(1).and_raise_error(NoMethodError) }
8 it { is_expected.to run.with_params({}).and_raise_error(NoMethodError) }
9 it { is_expected.to run.with_params(true).and_raise_error(NoMethodError) }
11 context 'when squeezing a single string' do
12 it { is_expected.to run.with_params('').and_return('') }
13 it { is_expected.to run.with_params('a').and_return('a') }
14 it { is_expected.to run.with_params('aaaaaaaaa').and_return('a') }
15 it { is_expected.to run.with_params('aaaaaaaaa', 'a').and_return('a') }
16 it { is_expected.to run.with_params('aaaaaaaaabbbbbbbbbbcccccccccc', 'b-c').and_return('aaaaaaaaabc') }
19 context 'with UTF8 and double byte characters' do
20 it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậậậậ').and_return('ậ') }
21 it { is_expected.to run.with_params('語語語語語語語', '語').and_return('語') }
22 it { is_expected.to run.with_params('ậậậậậậậậậậậậậậậậậ語語語語©©©©©', '©').and_return('ậậậậậậậậậậậậậậậậậ語語語語©') }
25 context 'when squeezing values in an array' do
28 .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc']) \
29 .and_return(['', 'a', 'a', 'abc'])
33 .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'a') \
34 .and_return(['', 'a', 'a', 'abbbbbbbbbbcccccccccc'])
38 .with_params(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabbbbbbbbbbcccccccccc'], 'b-c') \
39 .and_return(['', 'a', 'aaaaaaaaa', 'aaaaaaaaabc'])
43 context 'when using a class extending String' do
44 it 'calls its squeeze method' do
45 value = AlsoString.new('aaaaaaaaa')
46 expect_any_instance_of(AlsoString).to receive(:squeeze).and_return('foo') # rubocop:disable RSpec/AnyInstance
47 expect(subject).to run.with_params(value).and_return('foo')