summaryrefslogtreecommitdiff
path: root/code/environments/production/modules/stdlib/spec/acceptance/bool2num_spec.rb
blob: 2a62435195e600657da5065c1a51aa2db46f6684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'spec_helper_acceptance'

describe 'bool2num function' do
  describe 'success' do
    %w[false f 0 n no].each do |bool|
      pp1 = <<-DOC
        $input = "#{bool}"
        $output = bool2num($input)
        notify { "$output": }
      DOC
      it "should convert a given boolean, #{bool}, to 0" do
        apply_manifest(pp1, :catch_failures => true) do |r|
          expect(r.stdout).to match(%r{Notice: 0})
        end
      end
    end

    %w[true t 1 y yes].each do |bool|
      pp2 = <<-DOC
        $input = "#{bool}"
        $output = bool2num($input)
        notify { "$output": }
      DOC
      it "should convert a given boolean, #{bool}, to 1" do
        apply_manifest(pp2, :catch_failures => true) do |r|
          expect(r.stdout).to match(%r{Notice: 1})
        end
      end
    end
  end
end