summaryrefslogtreecommitdiff
path: root/spec/unit/parser/functions/search_spec.rb
blob: 54054bd6a298eef7a99b29102b0b95912aae0f94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#! /usr/bin/env ruby
require 'spec_helper'

describe "the 'search' function" do
  before :all do
    Puppet::Parser::Functions.autoloader.loadall
  end

  let :node     do Puppet::Node.new('localhost') end
  let :compiler do Puppet::Parser::Compiler.new(node) end
  let :scope    do Puppet::Parser::Scope.new(compiler) end

  it "should exist" do
    Puppet::Parser::Functions.function("search").should == "function_search"
  end

  it "should invoke #add_namespace on the scope for all inputs" do
    scope.expects(:add_namespace).with("where")
    scope.expects(:add_namespace).with("what")
    scope.expects(:add_namespace).with("who")
    scope.function_search(["where", "what", "who"])
  end

  it "is deprecated" do
    Puppet.expects(:deprecation_warning).with("The 'search' function is deprecated. See http://links.puppetlabs.com/search-function-deprecation")
    scope.function_search(['wat'])
  end
end