source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/spec/functions/uriescape_spec.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 8 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

  • Property svn:executable set to *
File size: 1.7 KB
Line 
1require 'spec_helper'
2
3describe '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) }
7 it {
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)
10 }
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/) }
14 end
15
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')
20 end
21 end
22
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")
28 end
29 end
30
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"]) }
35 end
36end
Note: See TracBrowser for help on using the repository browser.