1 #! /usr/bin/env ruby -S rspec
4 describe "the keys function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("keys")).to eq("function_keys")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_keys([]) }.to( raise_error(Puppet::ParseError))
15 it "should return an array of keys when given a hash" do
16 result = scope.function_keys([{'a'=>1, 'b'=>2}])
17 # =~ performs 'array with same elements' (set) matching
18 # For more info see RSpec::Matchers::MatchArray
19 expect(result).to match_array(['a','b'])