str2bool_spec.rb 949 B

1234567891011121314151617181920212223
  1. require 'spec_helper'
  2. describe 'str2bool' 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('true', 'extra').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i)
  8. }
  9. it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Unknown type of boolean given}) }
  10. describe 'when testing values that mean "true"' do
  11. ['TRUE', '1', 't', 'y', 'true', 'yes', true].each do |value|
  12. it { is_expected.to run.with_params(value).and_return(true) }
  13. end
  14. end
  15. describe 'when testing values that mean "false"' do
  16. ['FALSE', '', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined'].each do |value|
  17. it { is_expected.to run.with_params(value).and_return(false) }
  18. end
  19. end
  20. end