3 describe 'uriescape' do
4 describe 'signature validation' do
5 it { is_expected.not_to eq(nil) }
6 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
8 pending("Current implementation ignores parameters after the first.")
9 is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
11 it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
12 it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
13 it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /Requires either array or string to work/) }
16 describe 'handling normal strings' do
17 it 'should call ruby\'s URI.escape function' do
18 URI.expects(:escape).with('uri_string').returns('escaped_uri_string').once
19 is_expected.to run.with_params('uri_string').and_return('escaped_uri_string')
23 describe 'handling classes derived from String' do
24 it 'should call ruby\'s URI.escape function' do
25 uri_string = AlsoString.new('uri_string')
26 URI.expects(:escape).with(uri_string).returns('escaped_uri_string').once
27 is_expected.to run.with_params(uri_string).and_return("escaped_uri_string")
31 describe 'strings in arrays handling' do
32 it { is_expected.to run.with_params([]).and_return([]) }
33 it { is_expected.to run.with_params(["one}", "two"]).and_return(["one%7D", "two"]) }
34 it { is_expected.to run.with_params(["one}", 1, true, {}, "two"]).and_return(["one%7D", 1, true, {}, "two"]) }