2011-06-29 22:21:55 +02:00
|
|
|
#!/usr/bin/env rspec
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2011-08-05 09:25:03 +02:00
|
|
|
describe "the parseyaml function" do
|
2011-06-29 22:21:55 +02:00
|
|
|
before :all do
|
|
|
|
Puppet::Parser::Functions.autoloader.loadall
|
|
|
|
end
|
|
|
|
|
|
|
|
before :each do
|
|
|
|
@scope = Puppet::Parser::Scope.new
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2011-08-05 09:25:03 +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
|
2011-08-05 09:25:03 +02:00
|
|
|
result = @scope.function_parseyaml([yaml])
|
2011-06-29 22:21:55 +02:00
|
|
|
result.should(eq(['aaa','bbb','ccc']))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|