X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=modules%2Fstdlib%2Fspec%2Funit%2Fpuppet%2Fparser%2Ffunctions%2Fparsejson_spec.rb;fp=modules%2Fstdlib%2Fspec%2Funit%2Fpuppet%2Fparser%2Ffunctions%2Fparsejson_spec.rb;h=26eea360353658741ca75a8bbe8a7590a22c96de;hb=75e1859b97ece24e50398736c44b27133ef067c9;hp=0000000000000000000000000000000000000000;hpb=4ee17aa1cb1dbd80715204aa062faa4d920c4070;p=dsa-puppet.git diff --git a/modules/stdlib/spec/unit/puppet/parser/functions/parsejson_spec.rb b/modules/stdlib/spec/unit/puppet/parser/functions/parsejson_spec.rb new file mode 100644 index 00000000..26eea360 --- /dev/null +++ b/modules/stdlib/spec/unit/puppet/parser/functions/parsejson_spec.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env rspec +require 'spec_helper' + +describe "the parsejson function" do + before :all do + Puppet::Parser::Functions.autoloader.loadall + end + + before :each do + @scope = Puppet::Parser::Scope.new + end + + it "should exist" do + Puppet::Parser::Functions.function("parsejson").should == "function_parsejson" + end + + it "should raise a ParseError if there is less than 1 arguments" do + lambda { @scope.function_parsejson([]) }.should( raise_error(Puppet::ParseError)) + end + + it "should convert JSON to a data structure" do + json = <<-EOS +["aaa","bbb","ccc"] +EOS + result = @scope.function_parsejson([json]) + result.should(eq(['aaa','bbb','ccc'])) + end + +end