is_array_spec.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. require 'spec_helper'
  2. describe 'is_array' 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 {
  6. pending('Current implementation ignores parameters after the first.')
  7. is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
  8. }
  9. it { is_expected.to run.with_params([]).and_return(true) }
  10. it { is_expected.to run.with_params(['one']).and_return(true) }
  11. it { is_expected.to run.with_params([1]).and_return(true) }
  12. it { is_expected.to run.with_params([{}]).and_return(true) }
  13. it { is_expected.to run.with_params([[]]).and_return(true) }
  14. it { is_expected.to run.with_params('').and_return(false) }
  15. it { is_expected.to run.with_params('one').and_return(false) }
  16. it { is_expected.to run.with_params(1).and_return(false) }
  17. it { is_expected.to run.with_params({}).and_return(false) }
  18. context 'with deprecation warning' do
  19. after(:each) do
  20. ENV.delete('STDLIB_LOG_DEPRECATIONS')
  21. end
  22. # Checking for deprecation warning, which should only be provoked when the env variable for it is set.
  23. it 'displays a single deprecation' do
  24. ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
  25. scope.expects(:warning).with(includes('This method is deprecated'))
  26. is_expected.to run.with_params(['1.2.3.4']).and_return(true)
  27. end
  28. it 'displays no warning for deprecation' do
  29. ENV['STDLIB_LOG_DEPRECATIONS'] = 'false'
  30. scope.expects(:warning).with(includes('This method is deprecated')).never
  31. is_expected.to run.with_params(['1.2.3.4']).and_return(true)
  32. end
  33. end
  34. end