]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/parsejson_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / parsejson_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the parsejson function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should exist" do
8     expect(Puppet::Parser::Functions.function("parsejson")).to eq("function_parsejson")
9   end
10
11   it "should raise a ParseError if there is less than 1 arguments" do
12     expect { scope.function_parsejson([]) }.to( raise_error(Puppet::ParseError))
13   end
14
15   it "should convert JSON to a data structure" do
16     json = <<-EOS
17 ["aaa","bbb","ccc"]
18 EOS
19     result = scope.function_parsejson([json])
20     expect(result).to(eq(['aaa','bbb','ccc']))
21   end
22 end