2012-07-20 00:27:52 +02:00
|
|
|
#! /usr/bin/env ruby -S rspec
|
2011-06-29 22:21:55 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2011-08-05 09:25:03 +02:00
|
|
|
describe "the parseyaml function" do
|
2012-07-20 01:14:37 +02:00
|
|
|
let(:scope) { PuppetlabsSpec::PuppetSeams.parser_scope }
|
2011-06-29 22:21:55 +02:00
|
|
|
|
|
|
|
it "should exist" do
|
2011-08-05 09:25:03 +02:00
|
|
|
Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml"
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise a ParseError if there is less than 1 arguments" do
|
2012-07-20 01:14:37 +02:00
|
|
|
lambda { scope.function_parseyaml([]) }.should( raise_error(Puppet::ParseError))
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should convert YAML to a data structure" do
|
|
|
|
yaml = <<-EOS
|
|
|
|
- aaa
|
|
|
|
- bbb
|
|
|
|
- ccc
|
|
|
|
EOS
|
2012-07-20 01:14:37 +02:00
|
|
|
result = scope.function_parseyaml([yaml])
|
2011-06-29 22:21:55 +02:00
|
|
|
result.should(eq(['aaa','bbb','ccc']))
|
|
|
|
end
|
|
|
|
end
|