source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/spec/functions/validate_re_spec.rb@ 30960

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

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1require 'spec_helper'
2
3describe 'validate_re' do
4 after(:all) do
5 ENV.delete('STDLIB_LOG_DEPRECATIONS')
6 end
7
8 # Checking for deprecation warning
9 it 'should display a single deprecation' do
10 ENV['STDLIB_LOG_DEPRECATIONS'] = "true"
11 scope.expects(:warning).with(includes('This method is deprecated'))
12 is_expected.to run.with_params('', '')
13 end
14
15 describe 'signature validation' do
16 it { is_expected.not_to eq(nil) }
17 it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
18 it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
19 it { is_expected.to run.with_params('', '', '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
20
21 describe 'valid inputs' do
22 it { is_expected.to run.with_params('', '') }
23 it { is_expected.to run.with_params('', ['']) }
24 it { is_expected.to run.with_params('', [''], 'custom error') }
25 it { is_expected.to run.with_params('one', '^one') }
26 it { is_expected.to run.with_params('one', [ '^one', '^two' ]) }
27 it { is_expected.to run.with_params('one', [ '^one', '^two' ], 'custom error') }
28 end
29
30 describe 'invalid inputs' do
31 it { is_expected.to run.with_params('', []).and_raise_error(Puppet::ParseError, /does not match/) }
32 it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
33 it { is_expected.to run.with_params('', 'two').and_raise_error(Puppet::ParseError, /does not match/) }
34 it { is_expected.to run.with_params('', ['two']).and_raise_error(Puppet::ParseError, /does not match/) }
35 it { is_expected.to run.with_params('', ['two'], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
36 it { is_expected.to run.with_params('notone', '^one').and_raise_error(Puppet::ParseError, /does not match/) }
37 it { is_expected.to run.with_params('notone', [ '^one', '^two' ]).and_raise_error(Puppet::ParseError, /does not match/) }
38 it { is_expected.to run.with_params('notone', [ '^one', '^two' ], 'custom error').and_raise_error(Puppet::ParseError, /custom error/) }
39
40 describe 'non-string inputs' do
41 [
42 1, # Fixnum
43 3.14, # Float
44 nil, # NilClass
45 true, # TrueClass
46 false, # FalseClass
47 ["10"], # Array
48 :key, # Symbol
49 {:key=>"val"}, # Hash
50 ].each do |input|
51 it { is_expected.to run.with_params(input, '.*').and_raise_error(Puppet::ParseError, /needs to be a String/) }
52 end
53 end
54 end
55 end
56end
Note: See TracBrowser for help on using the repository browser.