puppetlabs-stdlib/spec/acceptance/bool2num_spec.rb

35 lines
945 B
Ruby
Raw Normal View History

#! /usr/bin/env ruby -S rspec
require 'spec_helper_acceptance'
describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
2014-04-09 00:04:55 +02:00
describe 'success' do
['false', 'f', '0', 'n', 'no'].each do |bool|
it "should convert a given boolean, #{bool}, to 0" do
2014-04-09 00:04:55 +02:00
pp = <<-EOS
$input = "#{bool}"
2014-04-09 00:04:55 +02:00
$output = bool2num($input)
notify { "$output": }
2014-04-09 00:04:55 +02:00
EOS
2014-04-09 00:04:55 +02:00
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/Notice: 0/)
end
end
end
2014-04-09 00:04:55 +02:00
['true', 't', '1', 'y', 'yes'].each do |bool|
it "should convert a given boolean, #{bool}, to 1" do
2014-04-09 00:04:55 +02:00
pp = <<-EOS
$input = "#{bool}"
2014-04-09 00:04:55 +02:00
$output = bool2num($input)
notify { "$output": }
2014-04-09 00:04:55 +02:00
EOS
2014-04-09 00:04:55 +02:00
apply_manifest(pp, :catch_failures => true) do |r|
expect(r.stdout).to match(/Notice: 1/)
end
end
end
end
end