1 #! /usr/bin/env ruby -S rspec
4 describe "the delete_at function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("delete_at")).to eq("function_delete_at")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_delete_at([]) }.to( raise_error(Puppet::ParseError))
15 it "should delete an item at specified location from an array" do
16 result = scope.function_delete_at([['a','b','c'],1])
17 expect(result).to(eq(['a','c']))
20 it "should not change origin array passed as argument" do
21 origin_array = ['a','b','c','d']
22 result = scope.function_delete_at([origin_array, 1])
23 expect(origin_array).to(eq(['a','b','c','d']))