2011-06-29 22:21:55 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'str2bool' do
|
|
|
|
it { is_expected.not_to eq(nil) }
|
|
|
|
it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
|
|
|
|
it {
|
|
|
|
pending("Current implementation ignores parameters after the first.")
|
|
|
|
is_expected.to run.with_params('true', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i)
|
|
|
|
}
|
|
|
|
it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, /Unknown type of boolean given/) }
|
2011-06-29 22:21:55 +02:00
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'when testing values that mean "true"' do
|
2015-09-03 19:31:51 +02:00
|
|
|
[ 'TRUE','1', 't', 'y', 'true', 'yes', true ].each do |value|
|
2015-06-01 13:21:59 +02:00
|
|
|
it { is_expected.to run.with_params(value).and_return(true) }
|
|
|
|
end
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'when testing values that mean "false"' do
|
2015-09-03 19:31:51 +02:00
|
|
|
[ 'FALSE','', '0', 'f', 'n', 'false', 'no', false, 'undef', 'undefined' ].each do |value|
|
2015-06-01 13:21:59 +02:00
|
|
|
it { is_expected.to run.with_params(value).and_return(false) }
|
|
|
|
end
|
2012-12-17 14:22:36 +01:00
|
|
|
end
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|