summaryrefslogtreecommitdiff
path: root/spec/unit/parser/functions/digest_spec.rb
blob: e3c0762d4c18cade1e5f6126849329996230a58b (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
29
30
31
#!/usr/bin/env rspec
require 'spec_helper'

describe "the digest function", :uses_checksums => true do
  before :all do
    Puppet::Parser::Functions.autoloader.loadall
  end

  before :each do
    n = Puppet::Node.new('unnamed')
    c = Puppet::Parser::Compiler.new(n)
    @scope = Puppet::Parser::Scope.new(c)
  end

  it "should exist" do
    Puppet::Parser::Functions.function("digest").should == "function_digest"
  end

  with_digest_algorithms do
    it "should use the proper digest function" do
      result = @scope.function_digest([plaintext])
      result.should(eql( checksum ))
    end

    it "should only accept one parameter" do
      expect do
        @scope.function_digest(['foo', 'bar'])
      end.to raise_error(ArgumentError)
    end
  end
end