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'
|
|
|
|
|
|
|
|
describe "the keys function" do
|
2012-07-23 17:28:06 +02:00
|
|
|
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
2011-06-29 22:21:55 +02:00
|
|
|
|
|
|
|
it "should exist" do
|
|
|
|
Puppet::Parser::Functions.function("keys").should == "function_keys"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise a ParseError if there is less than 1 arguments" do
|
2012-01-12 02:39:15 +01:00
|
|
|
lambda { scope.function_keys([]) }.should( raise_error(Puppet::ParseError))
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|
|
|
|
|
2011-07-24 01:39:17 +02:00
|
|
|
it "should return an array of keys when given a hash" do
|
2012-01-12 02:39:15 +01:00
|
|
|
result = scope.function_keys([{'a'=>1, 'b'=>2}])
|
|
|
|
# =~ performs 'array with same elements' (set) matching
|
|
|
|
# For more info see RSpec::Matchers::MatchArray
|
|
|
|
result.should =~ ['a','b']
|
2011-07-24 01:39:17 +02:00
|
|
|
end
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|