1 | require 'spec_helper'
|
---|
2 |
|
---|
3 | describe 'validate_string' 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 |
|
---|
19 | describe 'valid inputs' do
|
---|
20 | it { is_expected.to run.with_params('') }
|
---|
21 | it { is_expected.to run.with_params(nil) }
|
---|
22 | it { is_expected.to run.with_params('one') }
|
---|
23 | it { is_expected.to run.with_params('one', 'two') }
|
---|
24 | end
|
---|
25 |
|
---|
26 | describe 'invalid inputs' do
|
---|
27 | it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /is not a string/) }
|
---|
28 | it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, /is not a string/) }
|
---|
29 | it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, /is not a string/) }
|
---|
30 | it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, /is not a string/) }
|
---|
31 | end
|
---|
32 | end
|
---|
33 | end
|
---|