bool2num_spec.rb 821 B

12345678910111213141516171819202122232425262728293031
  1. require 'spec_helper_acceptance'
  2. describe 'bool2num function' do
  3. describe 'success' do
  4. %w[false f 0 n no].each do |bool|
  5. pp1 = <<-DOC
  6. $input = "#{bool}"
  7. $output = bool2num($input)
  8. notify { "$output": }
  9. DOC
  10. it "should convert a given boolean, #{bool}, to 0" do
  11. apply_manifest(pp1, :catch_failures => true) do |r|
  12. expect(r.stdout).to match(%r{Notice: 0})
  13. end
  14. end
  15. end
  16. %w[true t 1 y yes].each do |bool|
  17. pp2 = <<-DOC
  18. $input = "#{bool}"
  19. $output = bool2num($input)
  20. notify { "$output": }
  21. DOC
  22. it "should convert a given boolean, #{bool}, to 1" do
  23. apply_manifest(pp2, :catch_failures => true) do |r|
  24. expect(r.stdout).to match(%r{Notice: 1})
  25. end
  26. end
  27. end
  28. end
  29. end