]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/dirname_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / dirname_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the dirname function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should exist" do
8     expect(Puppet::Parser::Functions.function("dirname")).to eq("function_dirname")
9   end
10
11   it "should raise a ParseError if there is less than 1 arguments" do
12     expect { scope.function_dirname([]) }.to( raise_error(Puppet::ParseError))
13   end
14
15   it "should raise a ParseError if there is more than 1 argument" do
16     expect { scope.function_dirname(['a', 'b']) }.to( raise_error(Puppet::ParseError))
17   end
18
19   it "should return dirname for an absolute path" do
20     result = scope.function_dirname(['/path/to/a/file.ext'])
21     expect(result).to(eq('/path/to/a'))
22   end
23
24   it "should return dirname for a relative path" do
25     result = scope.function_dirname(['path/to/a/file.ext'])
26     expect(result).to(eq('path/to/a'))
27   end
28
29   it "should complain about hash argument" do
30     expect { scope.function_dirname([{}]) }.to( raise_error(Puppet::ParseError))
31   end
32   it "should complain about list argument" do
33     expect { scope.function_dirname([[]]) }.to( raise_error(Puppet::ParseError))
34   end
35   it "should complain about numeric argument" do
36     expect { scope.function_dirname([2112]) }.to( raise_error(Puppet::ParseError))
37   end
38 end