X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fmember_spec.rb;h=8988632a253a7a6ac18e534d34a508d0bb6059f0;hb=6963202b4b62c2816655ac9532521b018fdf83bd;hp=1a1d7c66025b852b37420a652bf3cc038e08e012;hpb=a69999e580f8b3abd12446c2d6ad59e517651813;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/member_spec.rb b/3rdparty/modules/stdlib/spec/functions/member_spec.rb index 1a1d7c660..8988632a2 100755 --- a/3rdparty/modules/stdlib/spec/functions/member_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/member_spec.rb @@ -1,34 +1,23 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' -describe "the member function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - - it "should exist" do - expect(Puppet::Parser::Functions.function("member")).to eq("function_member") - end - - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_member([]) }.to( raise_error(Puppet::ParseError)) - end - - it "should return true if a member is in an array" do - result = scope.function_member([["a","b","c"], "a"]) - expect(result).to(eq(true)) - end - - it "should return false if a member is not in an array" do - result = scope.function_member([["a","b","c"], "d"]) - expect(result).to(eq(false)) - end - - it "should return true if a member array is in an array" do - result = scope.function_member([["a","b","c"], ["a", "b"]]) - expect(result).to(eq(true)) - end - - it "should return false if a member array is not in an array" do - result = scope.function_member([["a","b","c"], ["d", "e"]]) - expect(result).to(eq(false)) - end +describe 'member' do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) } + it { + pending("Current implementation ignores parameters after the first.") + is_expected.to run.with_params([], [], []).and_raise_error(Puppet::ParseError, /wrong number of arguments/i) + } + it { is_expected.to run.with_params([], '').and_return(false) } + it { is_expected.to run.with_params([], ['']).and_return(false) } + it { is_expected.to run.with_params([''], '').and_return(true) } + it { is_expected.to run.with_params([''], ['']).and_return(true) } + it { is_expected.to run.with_params([], 'one').and_return(false) } + it { is_expected.to run.with_params([], ['one']).and_return(false) } + it { is_expected.to run.with_params(['one'], 'one').and_return(true) } + it { is_expected.to run.with_params(['one'], ['one']).and_return(true) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'two']).and_return(true) } + it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ŧẅồ']).and_return(true) } + it { is_expected.to run.with_params(['one', 'two', 'three', 'four'], ['four', 'five']).and_return(false) } + it { is_expected.to run.with_params(['ọאּẹ', 'ŧẅồ', 'ţҺŗęē', 'ƒơџŕ'], ['ƒơџŕ', 'ƒί√ə']).and_return(false) } end