1 #! /usr/bin/env ruby -S rspec
4 describe "the rstrip function" do
5 let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
8 expect(Puppet::Parser::Functions.function("rstrip")).to eq("function_rstrip")
11 it "should raise a ParseError if there is less than 1 arguments" do
12 expect { scope.function_rstrip([]) }.to( raise_error(Puppet::ParseError))
15 it "should rstrip a string" do
16 result = scope.function_rstrip(["asdf "])
17 expect(result).to(eq('asdf'))
20 it "should rstrip each element in an array" do
21 result = scope.function_rstrip([["a ","b ", "c "]])
22 expect(result).to(eq(['a','b','c']))
25 it "should accept objects which extend String" do
26 class AlsoString < String
29 value = AlsoString.new('asdf ')
30 result = scope.function_rstrip([value])
31 result.should(eq('asdf'))