Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / validate_bool_spec.rb
1 require 'spec_helper'
2
3 describe 'validate_bool' do
4   after(:each) do
5     ENV.delete('STDLIB_LOG_DEPRECATIONS')
6   end
7
8   # Checking for deprecation warning
9   it 'displays a single deprecation' do
10     ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
11     expect(scope).to receive(:warning).with(include('This method is deprecated'))
12     is_expected.to run.with_params(true)
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, %r{wrong number of arguments}i) }
18   end
19
20   describe 'acceptable values' do
21     it { is_expected.to run.with_params(true) }
22     it { is_expected.to run.with_params(false) }
23     it { is_expected.to run.with_params(true, false, false, true) }
24   end
25
26   describe 'validation failures' do
27     it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
28     it { is_expected.to run.with_params({}).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
29     it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
30     it { is_expected.to run.with_params(true, 'one').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
31     it { is_expected.to run.with_params('one', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
32     it { is_expected.to run.with_params('true').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
33     it { is_expected.to run.with_params('false').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
34     it { is_expected.to run.with_params(true, 'false').and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
35     it { is_expected.to run.with_params('true', false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
36     it { is_expected.to run.with_params('true', false, false, false, false, false).and_raise_error(Puppet::ParseError, %r{is not a boolean}) }
37   end
38 end