is_bool_spec.rb 1.5 KB

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