]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/member_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / member_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the member function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should exist" do
8     expect(Puppet::Parser::Functions.function("member")).to eq("function_member")
9   end
10
11   it "should raise a ParseError if there is less than 1 arguments" do
12     expect { scope.function_member([]) }.to( raise_error(Puppet::ParseError))
13   end
14
15   it "should return true if a member is in an array" do
16     result = scope.function_member([["a","b","c"], "a"])
17     expect(result).to(eq(true))
18   end
19
20   it "should return false if a member is not in an array" do
21     result = scope.function_member([["a","b","c"], "d"])
22     expect(result).to(eq(false))
23   end
24
25   it "should return true if a member array is in an array" do
26     result = scope.function_member([["a","b","c"], ["a", "b"]])
27     expect(result).to(eq(true))
28   end
29
30   it "should return false if a member array is not in an array" do
31     result = scope.function_member([["a","b","c"], ["d", "e"]])
32     expect(result).to(eq(false))
33   end
34 end