upgrade to stdlib 4.6.1
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / bool2num_spec.rb
diff --git a/3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb b/3rdparty/modules/stdlib/spec/acceptance/bool2num_spec.rb
new file mode 100755 (executable)
index 0000000..52ff75b
--- /dev/null
@@ -0,0 +1,34 @@
+#! /usr/bin/env ruby -S rspec
+require 'spec_helper_acceptance'
+
+describe 'bool2num function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+  describe 'success' do
+    ['false', 'f', '0', 'n', 'no'].each do |bool|
+      it "should convert a given boolean, #{bool}, to 0" do
+        pp = <<-EOS
+        $input = "#{bool}"
+        $output = bool2num($input)
+        notify { "$output": }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/Notice: 0/)
+        end
+      end
+    end
+
+    ['true', 't', '1', 'y', 'yes'].each do |bool|
+      it "should convert a given boolean, #{bool}, to 1" do
+        pp = <<-EOS
+        $input = "#{bool}"
+        $output = bool2num($input)
+        notify { "$output": }
+        EOS
+
+        apply_manifest(pp, :catch_failures => true) do |r|
+          expect(r.stdout).to match(/Notice: 1/)
+        end
+      end
+    end
+  end
+end