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

Last change on this file since 30903 was 30903, checked in by davidb, 7 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.9 KB
Line 
1require 'spec_helper'
2
3describe 'validate_cmd' do
4 let(:touch) { File.exists?('/usr/bin/touch') ? '/usr/bin/touch' : '/bin/touch' }
5
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, /wrong number of arguments/i) }
9 it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
10 it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
11 it {
12 pending('should implement stricter type checking')
13 is_expected.to run.with_params([], '', '').and_raise_error(Puppet::ParseError, /content must be a string/)
14 }
15 it {
16 pending('should implement stricter type checking')
17 is_expected.to run.with_params('', [], '').and_raise_error(Puppet::ParseError, /checkscript must be a string/)
18 }
19 it {
20 pending('should implement stricter type checking')
21 is_expected.to run.with_params('', '', []).and_raise_error(Puppet::ParseError, /custom error message must be a string/)
22 }
23 end
24
25 context 'when validation fails' do
26 context 'with % placeholder' do
27 it { is_expected.to run.with_params('', "#{touch} % /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \S+ \/no\/such\/file' returned 1:.*(cannot touch|o such file or)/) }
28 it { is_expected.to run.with_params('', "#{touch} % /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
29 end
30 context 'without % placeholder' do
31 it { is_expected.to run.with_params('', "#{touch} /no/such/file").and_raise_error(Puppet::ParseError, /Execution of '#{touch} \/no\/such\/file \S+' returned 1:.*(cannot touch|o such file or)/) }
32 it { is_expected.to run.with_params('', "#{touch} /no/such/file", 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
33 end
34 end
35end
Note: See TracBrowser for help on using the repository browser.