Update stdlib
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / spec / acceptance / parseyaml_spec.rb
index 5819837..acbda46 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env ruby -S rspec
 require 'spec_helper_acceptance'
 
-describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
+describe 'parseyaml function' do
   describe 'success' do
     it 'parses valid yaml' do
       pp = <<-EOS
@@ -16,7 +16,21 @@ describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
       end
     end
   end
+
   describe 'failure' do
+    it 'returns the default value on incorrect yaml' do
+      pp = <<-EOS
+      $a = "---\nhunter: washere\ntests: passing\n:"
+      $o = parseyaml($a, {'tests' => 'using the default value'})
+      $tests = $o['tests']
+      notice(inline_template('tests are <%= @tests.inspect %>'))
+      EOS
+
+      apply_manifest(pp, :catch_failures => true) do |r|
+        expect(r.stdout).to match(/tests are "using the default value"/)
+      end
+    end
+
     it 'raises error on incorrect yaml' do
       pp = <<-EOS
       $a = "---\nhunter: washere\ntests: passing\n:"
@@ -30,6 +44,15 @@ describe 'parseyaml function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('o
       end
     end
 
-    it 'raises error on incorrect number of arguments'
+
+    it 'raises error on incorrect number of arguments' do
+      pp = <<-EOS
+      $o = parseyaml()
+      EOS
+
+      apply_manifest(pp, :expect_failures => true) do |r|
+        expect(r.stderr).to match(/wrong number of arguments/i)
+      end
+    end
   end
 end