Update puppetlabs/stdlib module
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / is_bool_spec.rb
1 require 'spec_helper'
2
3 describe 'is_bool' do
4   it { is_expected.not_to eq(nil) }
5   it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
6   it { is_expected.to run.with_params(true, false).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
7   it { is_expected.to run.with_params(true).and_return(true) }
8   it { is_expected.to run.with_params(false).and_return(true) }
9   it { is_expected.to run.with_params([1]).and_return(false) }
10   it { is_expected.to run.with_params([{}]).and_return(false) }
11   it { is_expected.to run.with_params([[]]).and_return(false) }
12   it { is_expected.to run.with_params([true]).and_return(false) }
13   it { is_expected.to run.with_params('true').and_return(false) }
14   it { is_expected.to run.with_params('false').and_return(false) }
15   context 'with deprecation warning' do
16     after(:each) do
17       ENV.delete('STDLIB_LOG_DEPRECATIONS')
18     end
19     # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
20     it 'displays a single deprecation' do
21       ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
22       expect(scope).to receive(:warning).with(include('This method is deprecated'))
23       is_expected.to run.with_params(true).and_return(true)
24     end
25     it 'displays no warning for deprecation' do
26       ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
27       expect(scope).to receive(:warning).with(include('This method is deprecated')).never
28       is_expected.to run.with_params(false).and_return(true)
29     end
30   end
31 end