X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Fspec%2Ffunctions%2Fflatten_spec.rb;h=0b08f35fd3131b96e66791b3ca276cc25b6456ac;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=de8c66d662c4da1e098d598b2adc1af77d5add9b;hpb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb b/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb old mode 100755 new mode 100644 index de8c66d66..0b08f35fd --- a/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb +++ b/3rdparty/modules/stdlib/spec/functions/flatten_spec.rb @@ -1,27 +1,16 @@ -#! /usr/bin/env ruby -S rspec require 'spec_helper' -describe "the flatten function" do - let(:scope) { PuppetlabsSpec::PuppetInternals.scope } - it "should exist" do - expect(Puppet::Parser::Functions.function("flatten")).to eq("function_flatten") - end +describe 'flatten', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do + it { is_expected.not_to eq(nil) } + it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params([], []).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) } + it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires array}) } + it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Requires array}) } - it "should raise a ParseError if there is less than 1 arguments" do - expect { scope.function_flatten([]) }.to( raise_error(Puppet::ParseError)) - end - - it "should raise a ParseError if there is more than 1 argument" do - expect { scope.function_flatten([[], []]) }.to( raise_error(Puppet::ParseError)) - end - - it "should flatten a complex data structure" do - result = scope.function_flatten([["a","b",["c",["d","e"],"f","g"]]]) - expect(result).to(eq(["a","b","c","d","e","f","g"])) - end - - it "should do nothing to a structure that is already flat" do - result = scope.function_flatten([["a","b","c","d"]]) - expect(result).to(eq(["a","b","c","d"])) - end + it { is_expected.to run.with_params([]).and_return([]) } + it { is_expected.to run.with_params(['one']).and_return(['one']) } + it { is_expected.to run.with_params([['one']]).and_return(['one']) } + it { is_expected.to run.with_params(['a', 'b', 'c', 'd', 'e', 'f', 'g']).and_return(['a', 'b', 'c', 'd', 'e', 'f', 'g']) } + it { is_expected.to run.with_params([['a', 'b', ['c', ['d', 'e'], 'f', 'g']]]).and_return(['a', 'b', 'c', 'd', 'e', 'f', 'g']) } + it { is_expected.to run.with_params(['ã', 'β', ['ĉ', ['đ', 'ẽ', 'ƒ', 'ġ']]]).and_return(['ã', 'β', 'ĉ', 'đ', 'ẽ', 'ƒ', 'ġ']) } end