]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/spec/functions/chomp_spec.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / spec / functions / chomp_spec.rb
1 #! /usr/bin/env ruby -S rspec
2 require 'spec_helper'
3
4 describe "the chomp function" do
5   let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
6
7   it "should exist" do
8     expect(Puppet::Parser::Functions.function("chomp")).to eq("function_chomp")
9   end
10
11   it "should raise a ParseError if there is less than 1 arguments" do
12     expect { scope.function_chomp([]) }.to( raise_error(Puppet::ParseError))
13   end
14
15   it "should chomp the end of a string" do
16     result = scope.function_chomp(["abc\n"])
17     expect(result).to(eq("abc"))
18   end
19
20   it "should accept objects which extend String" do
21     class AlsoString < String
22     end
23
24     value = AlsoString.new("abc\n")
25     result = scope.function_chomp([value])
26     result.should(eq("abc"))
27   end
28 end