|
3 | 3 | require 'spec_helper'
|
4 | 4 |
|
5 | 5 | describe 'uriescape' do
|
6 |
| - describe 'signature validation' do |
7 |
| - it { is_expected.not_to eq(nil) } |
8 |
| - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } |
9 |
| - it { |
10 |
| - pending('Current implementation ignores parameters after the first.') |
11 |
| - is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) |
12 |
| - } |
13 |
| - it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } |
14 |
| - it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } |
15 |
| - it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } |
16 |
| - end |
| 6 | + # URI.escape has been fully removed as of Ruby 3. Therefore, it will not work as it stand on Puppet 8. |
| 7 | + if Puppet::Util::Package.versioncmp(Puppet.version, '8.0.0').negative? |
| 8 | + describe 'signature validation' do |
| 9 | + it { is_expected.not_to eq(nil) } |
| 10 | + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } |
| 11 | + it { |
| 12 | + pending('Current implementation ignores parameters after the first.') |
| 13 | + is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) |
| 14 | + } |
| 15 | + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } |
| 16 | + it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } |
| 17 | + it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{Requires either array or string to work}) } |
| 18 | + end |
17 | 19 |
|
18 |
| - describe 'handling normal strings' do |
19 |
| - it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do |
20 |
| - expect(URI::DEFAULT_PARSER).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once |
21 |
| - is_expected.to run.with_params('uri_string').and_return('escaped_uri_string') |
| 20 | + describe 'handling normal strings' do |
| 21 | + it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do |
| 22 | + expect(URI::DEFAULT_PARSER).to receive(:escape).with('uri_string').and_return('escaped_uri_string').once |
| 23 | + is_expected.to run.with_params('uri_string').and_return('escaped_uri_string') |
| 24 | + end |
22 | 25 | end
|
23 |
| - end |
24 | 26 |
|
25 |
| - describe 'handling classes derived from String' do |
26 |
| - it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do |
27 |
| - uri_string = AlsoString.new('uri_string') |
28 |
| - expect(URI::DEFAULT_PARSER).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once |
29 |
| - is_expected.to run.with_params(uri_string).and_return('escaped_uri_string') |
| 27 | + describe 'handling classes derived from String' do |
| 28 | + it 'calls ruby\'s URI::DEFAULT_PARSER.escape function' do |
| 29 | + uri_string = AlsoString.new('uri_string') |
| 30 | + expect(URI::DEFAULT_PARSER).to receive(:escape).with(uri_string).and_return('escaped_uri_string').once |
| 31 | + is_expected.to run.with_params(uri_string).and_return('escaped_uri_string') |
| 32 | + end |
30 | 33 | end
|
31 |
| - end |
32 | 34 |
|
33 |
| - describe 'strings in arrays handling' do |
34 |
| - it { is_expected.to run.with_params([]).and_return([]) } |
35 |
| - it { is_expected.to run.with_params(['one}', 'two']).and_return(['one%7D', 'two']) } |
36 |
| - it { is_expected.to run.with_params(['one}', 1, true, {}, 'two']).and_return(['one%7D', 1, true, {}, 'two']) } |
| 35 | + describe 'strings in arrays handling' do |
| 36 | + it { is_expected.to run.with_params([]).and_return([]) } |
| 37 | + it { is_expected.to run.with_params(['one}', 'two']).and_return(['one%7D', 'two']) } |
| 38 | + it { is_expected.to run.with_params(['one}', 1, true, {}, 'two']).and_return(['one%7D', 1, true, {}, 'two']) } |
| 39 | + end |
37 | 40 | end
|
38 | 41 | end
|
0 commit comments