summaryrefslogtreecommitdiff
path: root/spec/functions
diff options
context:
space:
mode:
authorBryan Jen <bryan.jen@gmail.com>2015-09-21 11:20:35 -0700
committerBryan Jen <bryan.jen@gmail.com>2015-09-21 11:20:35 -0700
commit97bd656efbd4ef70bb321f728e0f611fa931ad02 (patch)
treeca2f93dd6d459eac114f1e0b5cac05ac02d519cd /spec/functions
parent9b1932c538354c1b360838c8cf7b942af314c99d (diff)
parent799c38e14e1583e676e2b25a9c1782fd40e29fff (diff)
downloadpuppet-stdlib-97bd656efbd4ef70bb321f728e0f611fa931ad02.tar.gz
puppet-stdlib-97bd656efbd4ef70bb321f728e0f611fa931ad02.tar.bz2
Merge pull request #527 from mhaskel/511_compatibility
Fix backwards compatibility from #511
Diffstat (limited to 'spec/functions')
-rwxr-xr-xspec/functions/parsejson_spec.rb6
-rwxr-xr-xspec/functions/parseyaml_spec.rb17
2 files changed, 16 insertions, 7 deletions
diff --git a/spec/functions/parsejson_spec.rb b/spec/functions/parsejson_spec.rb
index 5bea8af..a01f1f6 100755
--- a/spec/functions/parsejson_spec.rb
+++ b/spec/functions/parsejson_spec.rb
@@ -41,10 +41,10 @@ describe 'parsejson' do
end
- context 'with incorrect YAML data' do
- it 'should return "nil" if a default value should be returned but is not provided' do
+ context 'with incorrect JSON data' do
+ it 'should raise an error with invalid JSON and no default' do
is_expected.to run.with_params('').
- and_return(nil)
+ and_raise_error(PSON::ParserError)
end
it 'should support a structure for a default value' do
diff --git a/spec/functions/parseyaml_spec.rb b/spec/functions/parseyaml_spec.rb
index 492a1c9..fa947ca 100755
--- a/spec/functions/parseyaml_spec.rb
+++ b/spec/functions/parseyaml_spec.rb
@@ -40,12 +40,21 @@ describe 'parseyaml' do
end
- context 'with incorrect YAML data' do
- it 'should return "nil" if a default value should be returned but is not provided' do
- is_expected.to run.with_params('').
- and_return(nil)
+ context 'on a modern ruby', :unless => RUBY_VERSION == '1.8.7' do
+ it 'should raise an error with invalid YAML and no default' do
+ is_expected.to run.with_params('["one"').
+ and_raise_error(Psych::SyntaxError)
+ end
+ end
+
+ context 'when running on ruby 1.8.7, which does not have Psych', :if => RUBY_VERSION == '1.8.7' do
+ it 'should raise an error with invalid YAML and no default' do
+ is_expected.to run.with_params('["one"').
+ and_raise_error(ArgumentError)
+ end
end
+ context 'with incorrect YAML data' do
it 'should support a structure for a default value' do
is_expected.to run.with_params('', {'a' => '1'}).
and_return({'a' => '1'})